-
Notifications
You must be signed in to change notification settings - Fork 15
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
fix: using HtmlDisplay trait to show json in html #245
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -56,6 +56,8 @@ where | |||||
DropdownBtnType::Select => "select select-bordered w-[28rem] items-center", | ||||||
}; | ||||||
|
||||||
let node_ref = create_node_ref::<html::Input>(); | ||||||
|
||||||
view! { | ||||||
<div | ||||||
id=id | ||||||
|
@@ -66,7 +68,16 @@ where | |||||
class=("dropdown-top", dropdown_direction == DropdownDirection::Top) | ||||||
class=("dropdown-down", dropdown_direction == DropdownDirection::Down) | ||||||
> | ||||||
<label tabindex="0" class=format!("{} {}", class, btn_class)> | ||||||
<label | ||||||
tabindex="0" | ||||||
class=format!("{} {}", class, btn_class) | ||||||
on:click:undelegated=move |_| { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, how was this supposed to work ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't get your question There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i was asking how was this change helping in solving the autofocus issue, couldn't understand the logic by looking at the code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In terms of implementation, I have an input element ref, every click on the button, I am using the input element ref to focus on the input box. Can you specify what exactly you didn't understand? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To further add on this, the component library we are using keeps the dropdown mounted on the DOM, so autofocus do focus on the input box but since we make other interactions that focus is lost. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other way of doing this can be taking over the logic to display dropdown using signals, but I don't want to manually manage close for any click outside of dropdown. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
why is it always mounted ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ideally yes.
That's how daisy UI does it. |
||||||
if let Some(element) = node_ref.get() { | ||||||
let _ = element.focus(); | ||||||
} | ||||||
} | ||||||
> | ||||||
|
||||||
<i class=format!("{dropdown_icon}")></i> | ||||||
{dropdown_text} | ||||||
</label> | ||||||
|
@@ -86,7 +97,8 @@ where | |||||
type="text" | ||||||
class="grow" | ||||||
placeholder="Search" | ||||||
name=name | ||||||
ref_=node_ref | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wont this suffice ?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That wasn't working, so went ahead with this approach. |
||||||
name=name.clone() | ||||||
value=search_term.get_untracked() | ||||||
on:input=move |event| { | ||||||
set_search_term.set(event_target_value(&event)); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this tested? Or can we remove this because of @sauraww 's change earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tested, I am just getting rid of trim logic, as
html_display
will take care of showing these values without quotes in frontend.