[EuiFocusTrap] Migrate to function component#9599
Open
mgadewoll wants to merge 4 commits intoelastic:mainfrom
Open
[EuiFocusTrap] Migrate to function component#9599mgadewoll wants to merge 4 commits intoelastic:mainfrom
mgadewoll wants to merge 4 commits intoelastic:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors EuiFocusTrap (accessibility-critical focus management utility) from a class component to a hook-based function component while aiming to preserve existing behavior.
Changes:
- Replaced class lifecycle methods with
useEffect/useUpdateEffectand hook state for click-outside disabling - Reworked click-outside mouseup handling to use document-level listeners stored in a ref
- Consolidated prop defaulting via destructuring and continued support for
EuiProvidercomponent defaults viausePropsWithComponentDefaults
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d831551 to
70fc730
Compare
Collaborator
💚 Build SucceededHistory
cc @mgadewoll |
Collaborator
💚 Build Succeeded
History
cc @mgadewoll |
Contributor
Author
|
ℹ️ The changes were re-run in Kibana after merging main (on state of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
closes #9490
This PR refactors
EuiFocusTrapfrom a class component to a function component.API Changes
⚪ no API changes
Screenshots
Screen.Recording.2026-04-17.at.14.15.55.mov
Screen.Recording.2026-04-17.at.14.18.48.mov
Screen.Recording.2026-04-17.at.14.17.08.mov
Screen.Recording.2026-04-17.at.14.12.22.mov
Impact Assessment
Note: Most PRs should be tested in Kibana to help gauge their Impact before merging.
Impact level: 🟢 None
The refactor is a 1:1 functional and structural migration. There should not be any impact.
ℹ️ The changes were run in Kibana CI (🟢 CI build)
Release Readiness
QA instructions for reviewer
💻 EuiFocusTrap storybook
💻 React 18 strict mode testing codesandbox
💻 React 19 strict mode testing codesandbox
EuiFocusTrapwork as expected (see above linked codesandboxes)EuiFocusTrapdoes not return the focus. That's a pre-existing issue likely fromreact-focus-on. For the purpose of this migration PR this is in "parity".Checklist before marking Ready for Review
QA: Tested docs changesTests: Added/updated Jest, Cypress, and VRTChangelog: Added changelog entryBreaking changes: Addedbreaking changelabel (if applicable)Reviewer checklist