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

[docs][autocomplete] Fix duplicate autocomplete id #42086

Merged
merged 4 commits into from
May 3, 2024

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented May 1, 2024

We can't have duplicated id on a page. I noticed this in #42085. Part of the value of solving these errors, the more we have, the harder its to quickly spot regressions

SCR-20240501-pstw

https://validator.w3.org/nu/?doc=https%3A%2F%2Fdeploy-preview-39603--material-ui.netlify.app%2Fmaterial-ui%2Freact-autocomplete%2F

A regression from #34066

After: https://deploy-preview-42086--material-ui.netlify.app/material-ui/react-autocomplete/

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work docs Improvements or additions to the documentation component: autocomplete This is the name of the generic UI component, not the React module! labels May 1, 2024
@mui-bot
Copy link

mui-bot commented May 1, 2024

Netlify deploy preview

https://deploy-preview-42086--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against cf6704e

@zannager zannager requested a review from michaldudak May 1, 2024 16:38
@oliviertassinari oliviertassinari added the regression A bug, but worse label May 1, 2024
@michaldudak
Copy link
Member

Why do we even need the explicit id? It doesn't add anything of value to the demo.

@oliviertassinari
Copy link
Member Author

oliviertassinari commented May 2, 2024

@michaldudak The id was needed: #18283 (comment) (a side though: seeing this reinforces the idea that we should comment as much as possible, such a nice payoff 4 years after).

But since useId() was introduced in React 18: https://react.dev/blog/2022/03/29/react-v18#useid, the problem got solved by React.

It's a bit borderline to remove in the docs:

SCR-20240502-ozhb

https://tools-public.mui.com/prod/pages/npmVersion?package=react-dom

but I guess, why not? I have pushed a new commit.

@michaldudak
Copy link
Member

I understand the id is needed to wire the input to the label, but even if we use React 17 and automatically set the id only on the client, it's not really a problem. There won't be any layout shifts and I think it's safe to assume users with assistive technologies will need this in the brief moment before hydration.

@oliviertassinari
Copy link
Member Author

There won't be any layout shifts and I think it's safe to assume users with assistive technologies will need this in the brief moment before hydration.

Fair enough.

@oliviertassinari oliviertassinari merged commit 75e8f4a into mui:next May 3, 2024
19 checks passed
@oliviertassinari oliviertassinari deleted the fix-duplicate-id branch May 3, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation regression A bug, but worse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants