Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dropdown #210

Merged
merged 4 commits into from
Jun 26, 2024
Merged

Feature/dropdown #210

merged 4 commits into from
Jun 26, 2024

Conversation

kandrelczyk
Copy link
Contributor

Adding dropdown component. For now it's just a basic list with optional icon and disabled option.

@luoxiaozero
Copy link
Collaborator

I think it's a bit weird that the Dropdown popup doesn't close when clicking on the DropdownItem. Also, I think it would be better to remove the click event of the DropdownItem and add an on_select event to the Dropdown instead. https://www.naiveui.com/en-US/os-theme/components/dropdown#basic.vue

@kandrelczyk
Copy link
Contributor Author

Please take a look at this. Since we don't want to close the dropdown when clicking on disabled item I had to keep the previous closing method and add automatic close when on_select is called.

In previous commit I also introduced the call_on_click_outside method which is a common code between dropdown and popover but forgot to extract it. Now it's in utils and can be also used in future popselect and popconfirm components.

Let me know what you think. If this is fine I will update documentation.

# Dropdown

```rust demo
let value = create_rw_signal(None::<String>);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete this line.

thaw/src/dropdown/mod.rs Show resolved Hide resolved
if current_el == *body {
break;
};
let Some(dropdown_el) = element.get_untracked() else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropdown_el can be changed to a generic name.

{
let handle = window_event_listener(ev::click, move |ev| {
use leptos::wasm_bindgen::__rt::IntoJsResult;
if trigger_type != PopoverTriggerType::Click {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This judgment logic is not reflected in call_on_click_outside, resulting in Hover mode, click the button can also close the pop-up window.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this condition outside of call_on_click_outside so that for Hover trigger type the event is not set at all. Is that ok?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so.

transform-origin: inherit;
}

.thaw-dropdown-trigger {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete this line.

use thaw_components::{Binder, CSSTransition, Follower, FollowerPlacement};
pub use theme::DropdownTheme;

use leptos::{html::Div, leptos_dom::helpers::TimeoutHandle, *};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import: html::Div

thaw/src/dropdown/dropdown_item.rs Show resolved Hide resolved
@luoxiaozero
Copy link
Collaborator

The call_on_click_outside method is fine, but there are a few hiccups at the moment. #210 (comment)

@kandrelczyk
Copy link
Contributor Author

I think that's it. Demo page is also updated. Let me know if anything still needs fixing.

@luoxiaozero luoxiaozero merged commit 7685e99 into thaw-ui:main Jun 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants