Update multiple functional components to useGeneratedHtmlId hook#5195
Update multiple functional components to useGeneratedHtmlId hook#5195cee-chen merged 13 commits intoelastic:masterfrom
Conversation
- remove existing useMemo hook in favor of new helper - behavior should remain same as before
- replace useRefs with new hook - behavior should remain same as before
- replace useState with new hook - behavior should remain same as before
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5195/ |
cee-chen
left a comment
There was a problem hiding this comment.
QA before/after screencaps
|
|
||
| const typeIsSingle = type === 'single'; | ||
| const nameIfSingle = name || htmlIdGenerator()(); | ||
| const nameIfSingle = useGeneratedHtmlId({ conditionalId: name }); |
There was a problem hiding this comment.
| ); | ||
|
|
||
| const ariaId = htmlIdGenerator()(); | ||
| const ariaId = useGeneratedHtmlId(); |
There was a problem hiding this comment.
| const switchId = useGeneratedHtmlId({ conditionalId: id }); | ||
| const labelId = useGeneratedHtmlId({ conditionalId: labelProps?.id }); |
There was a problem hiding this comment.
[QA] This is a cleanup refactor and no behavior should have changed on https://eui.elastic.co/pr_5195/#/forms/form-controls#switch
| type ElementType = ReactElementType<typeof Element>; | ||
|
|
||
| const itemId = id || htmlIdGenerator()(); | ||
| const itemId = useGeneratedHtmlId({ conditionalId: id }); |
There was a problem hiding this comment.
| const editorId = useMemo(() => _editorId || htmlIdGenerator()(), [ | ||
| _editorId, | ||
| ]); | ||
| const editorId = useGeneratedHtmlId({ conditionalId: _editorId }); |
There was a problem hiding this comment.
[QA] This is a cleanup refactor and no behavior should have changed on https://eui.elastic.co/pr_5195/#/editors-syntax/markdown-editor
| return ( | ||
| <EuiCheckbox | ||
| id={htmlIdGenerator()()} | ||
| id={useGeneratedHtmlId()} |
There was a problem hiding this comment.
| }); | ||
|
|
||
| const randomHeadingId = htmlIdGenerator()(); | ||
| const randomHeadingId = useGeneratedHtmlId(); |
There was a problem hiding this comment.
| const resizerId = useGeneratedHtmlId({ | ||
| prefix: 'resizable-button', | ||
| conditionalId: id, | ||
| }); |
There was a problem hiding this comment.
[QA] All resizable_container changes are cleanup refactors and no behavior should have changed on https://eui.elastic.co/pr_5195/#/layout/resizable-container
| }) => { | ||
| const generatedId = htmlIdGenerator(); | ||
| const titleId = generatedId(); | ||
| const titleId = useGeneratedHtmlId(); |
There was a problem hiding this comment.
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5195/ |












Summary
Follow up to #5133: This PR updates our functional components to not regenerate our randomized HTML IDs on every component update/rerender.
Components addressed in separate PRs:
Components addressed in this PR:
Checklist
N/A - Individual component QA steps listed above.