Replies: 2 comments 3 replies
-
|
Could you share some example code to look at? |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
create_effect(cx, move |_| {
if show.get() {
if let Some(ref_input) = ref_input.get() {
ref_input.on_mount(|input| {
input.focus();
});
}
}
}); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When first rendering the element, the browser can set focus itself if I add
autofocusto the element, but since I open theinputconditionally using theShowcomponent I need a way to do that through leptos as well.As far as I can tell there's no "element got attached to the DOM" event in leptos.
I've also tried to switch from
Showto a closure returning aview!conditionally expecting that'd make leptos re-render the element every time the condition changes. And while the render function is getting called, theautofocusattribute doesn't seem to cause a re-focus the second time.Maybe leptos never actually creates a new
inputand just applies the difference instead?If so, do you have a suggestion for how to implement this seemingly simple functionality?
Beta Was this translation helpful? Give feedback.
All reactions