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
autofocus
to the element, but since I open theinput
conditionally using theShow
component 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
Show
to 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, theautofocus
attribute doesn't seem to cause a re-focus the second time.Maybe leptos never actually creates a new
input
and 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