Replies: 2 comments
-
|
I am trying to avoid requiring the developers to deal with the hidden input themselves with If you want to forward the focus just like Conform v0.9.1, you can render a hidden input similar to what you did previously or setup an event listener yourself. But I do plan to improve this and remove such need. One idea I have now is to give you a ref object that you can pass to the element you wanna focus to. e.g. function Example({ meta }) {
const control = useInputControl(meta);
return (
<CustomInput
ref={control.elementRef}
value={control.value}
onChange={control.change}
/>
);
} One minor issue with this approach is the typing. As the element could be anything. Although I only cares whether the element can be focused (i.e. Anything that is function Example({ meta }) {
const control = useInputControl(meta);
return (
<CustomInput
ref={element => {
control.elementRef.current = element;
}}
value={control.value}
onChange={control.change}
/>
);
} |
Beta Was this translation helpful? Give feedback.
-
|
Ok, so what I'm hearing is that it's not possible yet but it's on the roadmap? As for the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Conform automatically focuses the first invalid native input on submission attempts. In Conform v0.9.1, we could replicate that behavior for custom non-native input components by creating a hidden input, spreading Conform's input props on it, and adding our own
onFocushandler that would then "forward" the focus event to the custom component (usually something likemyCustomComponentRef.current?.focus()). How would we accomplish this in Conform v1?The UI library integration docs mention
control.focusandcontrol.blurfromuseInputControl, but those seem to be for communicating "the other direction", right? They would be useful in telling Conform the input was focused/blurred, but we need the opposite - to tell the custom input that Conform wants to focus it.Beta Was this translation helpful? Give feedback.
All reactions