Skip to content
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

Closed
matt-greenfield-15 opened this issue Sep 20, 2023 · 4 comments
Closed

Unable to set ID on Select component in v7 #4809

matt-greenfield-15 opened this issue Sep 20, 2023 · 4 comments
Labels
Fixed Completed issues that will be published with next patch (1.0.X)

Comments

@matt-greenfield-15
Copy link

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 input id 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();

@mateuscqueiros
Copy link
Contributor

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 :)

rtivital added a commit that referenced this issue Sep 21, 2023
@rtivital rtivital added the Fixed Completed issues that will be published with next patch (1.0.X) label Sep 21, 2023
@rtivital
Copy link
Member

The issue is resolved in 7.0.1

@matt-greenfield-15
Copy link
Author

Thank you both!

@bayerlse
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

4 participants