[EuiSuperSelect] Migrate to function component - #9972
Conversation
|
👋 Since this is a community submitted pull request, a Buildkite build has not been started automatically. Would an Elastic organization member please verify the contents of this pull request and kick off a build manually? |
| : undefined; | ||
|
|
||
| return ( | ||
| <RenderWithEuiStylesMemoizer> |
There was a problem hiding this comment.
nit: We don't need to do RenderWithEuiStylesMemoizer in a functional component, we can use the hook useEuiMemoizedStyles.
|
buildkite test this |
There was a problem hiding this comment.
🟡 Changes recommended
The new mount guard sets isMounted only in useEffect, which can prevent initial option focusing/onFocus in fast post-mount interactions and risks a behavioral regression.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Refactors EuiSuperSelect from a generic class component to a generic function component using React hooks, aiming to preserve existing API and keyboard/focus behavior while modernizing the implementation.
Changes:
- Migrated
EuiSuperSelectto a hook-based function component (useState,useRef,useEffect) while keeping public props and DOM structure stable. - Preserved focus management behaviors (initial option focus, disabled-option skipping, focus restoration) with mount guarding for async RAF focus.
- Updated type-only tests to align
@ts-expect-errordirectives with JSX prop-level diagnostics.
File summaries
| File | Description |
|---|---|
| packages/eui/src/components/form/super_select/super_select.tsx | Reimplements EuiSuperSelect as a function component with hook-based state, refs, and lifecycle equivalents. |
| packages/eui/src/components/form/super_select/super_select.test.tsx | Adjusts TS typing assertion comments to match the new JSX error locations. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| useEffect(() => { | ||
| isMounted.current = true; | ||
| if (isOpen) { | ||
| openPopover(); | ||
| } |
💚 Build Succeeded
|
💚 Build Succeeded
|
weronikaolejniczak
left a comment
There was a problem hiding this comment.
The overall migration looks fine but we will break Kibana with this update if we don't forwardRef and useImperativeHandle({ openPopover, closePopover }). See https://github.com/elastic/kibana/blob/main/x-pack/platform/packages/shared/response-ops/alerts-filters-form/components/alerts_solution_selector.tsx
Summary
EuiSuperSelectfrom a generic class component to a generic function component usinguseState,useRef, anduseEffect.isOpenbehavior, option focus order, disabled-option skipping, and control-button focus restoration.Fixes #9485.
API Changes
EuiSuperSelectScreenshots
Not applicable. This is an implementation-only refactor with no intended visual or DOM changes; all 13 focused snapshots remain unchanged.
Impact Assessment
@ts-expect-errorcomments moved to the prop diagnostics emitted for a function component. Runtime assertions and snapshots are unchanged.Impact level: 🟢 Low
Release Readiness
Documentation: Not applicable; no API or behavior change.Figma: Not applicable; no visual change.Migration guide: Not applicable; no consumer migration.Adoption plan: Not applicable; this completes the class-to-function migration requested in [EuiSuperSelect] Migrate from class to function component #9485.QA instructions for reviewer
From
packages/eui:The Cypress spec checks the user-visible behaviors most at risk in this migration:
Local validation performed with Node 24.19.0 and React 18:
yarn lint: passed with zero errors (repository-wide existing warnings remain).yarn test-staged: 368 suites, 5,302 tests, and 2,754 snapshots passed; 1 suite and 21 tests were skipped by the repository configuration.Checklist before marking Ready for Review
QA: CodeSandbox and Kibana testing are not needed for this internal refactor with unchanged API, DOM snapshots, and browser behavior.QA: No documentation changes.EuiSuperSelect. No VRT was run locally because there is no visual change.Changelog: No consumer-facing change; this PR should useskip-changelog.Breaking changes: Not applicable.Reviewer checklist