-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Focus on TextField is lost if variant is changed on the fly #20821
Comments
@keul Thanks for the report, however, I don't think that we want to support this use case. It will increase the bundle size and distract us from more important problems. |
@marcosvega91 Regarding your proposed fix, it makes me think of #14132. |
I proposed a fix that if i think better has not sense. So I deleted It. We can check if the variant is changed and the input has the current focus and trigger focus on the element on next render, but i think Is only a workaround and not a solution |
I think for uncontrolled components the state would be lost as well. It would definitely be nice to be able to switch variants but the amount of work required isn't justified compared to the gain. Generally you don't switch variants since you only have a single variant per form anyway. |
@eps1lon @oliviertassinari I updated the codesandox with an uncontrolled example and there's the same issue. Thanks all for your time! |
Current Behavior 😯
If the
variant
property of a TextField is changed on the fly the focus on the field is lostExpected Behavior 🤔
Would be nice if focus is kept.
Steps to Reproduce 🕹
Go to https://odtfp.csb.app/
_
char (which enable the error state)_
(so exit the "error state"Context 🔦
What I was trying to achieve is to have a better highlight of the field error so I'm switching from "standard" to "filled" variant on the fly in case of error.
I perfectly know that I can have the same visual behavior just using styles, and I'm going in this direction, but I was not sure if this should be threat as a minor bug or not, so I'm reporting this.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: