-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Unable to set ID on Select component in v7 #4809
Comments
After some digging, I found out that the useId() hook (coming from @mantine/hooks) can receive a parameter with a static id that may or may not be undefined. If no parameter is set or the id is undefined, it returns a mantine-generated id and that was causing this issue in the Select (no static id was being passed to the hook). Also, there were some other components using the function useId coming from React which does not accept any parameters. I'm submitting a PR with these fixes in a second :) |
The issue is resolved in 7.0.1 |
Thank you both! |
It seems that in 7.13.2 its not working. When setting a custom on ID on TextArea Component, it uses a mantine id instead: mantine-rt4zdbr0s-target |
Steps to reproduce
Why it matters
I'd imagine for most uses cases this is not an issue. But I'm using my own InputWrapper component and as per these instructions I set an ID on both the label and the input.
The issue means my label
for
and inputid
do not match.Possible fix
It could be that we just need to first check the prop here before creating the new id. Something like
const _id = id || useId();
mantine/src/mantine-core/src/components/Select/Select.tsx
Line 127 in d41e95a
The text was updated successfully, but these errors were encountered: