Repository navigation
[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? |
|
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.
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
…yout mount effect
|
Thanks @weronikaolejniczak — all three review points are addressed in 097ff56.
|
|
This PR contains breaking changes. The opener of this pull request is asked to perform the following due diligence steps below, to assist EUI in our next Kibana upgrade:
|
Packed from mehuljariwala/eui#fix/9485-super-select-hooks (elastic/eui#9972) so Kibana CI can typecheck EuiSuperSelectRef before publish. Drop this commit from the real version bump. Co-authored-by: Cursor <[email protected]>
Packed from mehuljariwala/eui#fix/9485-super-select-hooks (elastic/eui#9972) so Kibana CI can typecheck EuiSuperSelectRef before publish. Drop this commit from the real version bump. Co-authored-by: Cursor <[email protected]>
|
buildkite test this |
weronikaolejniczak
left a comment
There was a problem hiding this comment.
Thank you for the contribution @mehuljariwala 🙌🏻 The way you implemented it is great! I'll take it from here and add a small commit to the PR.
Packed from mehuljariwala/eui#fix/9485-super-select-hooks (elastic/eui#9972). Includes 120 i18n mapping for euiTimeWindowButtons.label so types pass against this tarball. Drop this commit from the real version bump. Co-authored-by: Cursor <[email protected]>
|
buildkite test this |
Co-authored-by: Cursor <[email protected]>
…ct-hooks Co-authored-by: Cursor <[email protected]> # Conflicts: # packages/release-cli/kibana-prep-commits
💚 Build Succeeded
History
|
💚 Build Succeeded
History
|
## Dependency updates `@elastic/eui` - v121.0.0 ⏩ v122.0.0 `@elastic/eui-illustrations` - v1.0.2 ⏩ v1.1.0 `@elastic/eui-test-helpers` - v1.6.0 ⏩ v1.7.0 ## Changes - Cherry-picked staged Kibana prep commits from `kibana-prep-commits`: - #288940 (`1fdf41c`) — type `EuiSuperSelect` refs as `EuiSuperSelectRef` following the breaking `ref` change in elastic/eui#9972 - #290240 (`54cae3c`) — update tests, page objects, the EUI i18n mapping, and translation files for the removed `euiSelectableListItem.checkedOption` screen-reader text (elastic/eui#9850) - Synced EUI i18n tokens: added `euiKeyboardShortcuts.cmd`, `euiKeyboardShortcuts.copyTitle`, and `euiKeyboardShortcuts.copyDescription` to `i18n_eui_mapping.tsx` and updated the `i18n_service` snapshot ## Package updates ### `@elastic/eui` [v122.0.0](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md) - Added Ctrl/Cmd+C support on `EuiDataGrid` to copy the focused cell value when no text is selected ([#9995](elastic/eui#9995)) **Bug fixes** - Fixed `EuiDataGrid` copy/paste shifting body rows one column right of the headers when control columns were present ([#9954](elastic/eui#9954)) **Breaking changes** - Changed the `ref` of `EuiSuperSelect` from the class instance to an `EuiSuperSelectRef` object, which exposes `openPopover()` and `closePopover()` ([#9972](elastic/eui#9972)) **Accessibility** - Improved the accessibility of `EuiSelectable` by removing redundant "Checked option." screen-reader text (checked state is already conveyed via `aria-checked`/`aria-selected`) ([#9850](elastic/eui#9850)) - Improved the accessibility of `EuiSelectable` and `EuiComboBox` by moving the `title` attribute to the inner text element, preventing duplicate screen-reader announcements of option names ([#9850](elastic/eui#9850)) ### `@elastic/eui-illustrations` [v1.1.0](https://github.com/elastic/eui/blob/main/packages/illustrations/changelogs/CHANGELOG_2026.md) - Added `attachments`, `detection`, `discovery`, `fieldExtraction`, `generatePreview`, `knowledgeIndicator`, `noData`, `processorsError`, `processorsLoading`, and `processorsPreview` illustrations ([#10001](elastic/eui#10001)) ### `@elastic/eui-test-helpers` [v1.7.0](https://github.com/elastic/eui/blob/main/packages/test-helpers/changelogs/CHANGELOG_2026.md) - Added `EuiTreeViewObject`, a Playwright Component Object for `EuiTreeView` ([#10025](elastic/eui#10025)) - Added `EuiToolTipObject`, a Playwright Component Object for `EuiToolTip` ([#10026](elastic/eui#10026)) - Added `EuiContextMenuObject`, a Playwright Component Object for `EuiContextMenu` ([#10013](elastic/eui#10013)) - Added `EuiColorPickerObject`, a Playwright Component Object for `EuiColorPicker` ([#10020](elastic/eui#10020)) **Bug fixes** - Fixed Component Objects not finding components whose `data-test-subj` holds several space-separated tokens, such as `EuiColorPicker`. The root now matches one token, following Kibana's `data-test-subj` convention ([#10015](elastic/eui#10015)) --------- Co-authored-by: Weronika Olejniczak <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Alexey Antonov <[email protected]> Co-authored-by: Lene Gadewoll <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
## Dependency updates `@elastic/eui` - v121.0.0 ⏩ v122.0.0 `@elastic/eui-illustrations` - v1.0.2 ⏩ v1.1.0 `@elastic/eui-test-helpers` - v1.6.0 ⏩ v1.7.0 ## Changes - Cherry-picked staged Kibana prep commits from `kibana-prep-commits`: - elastic#288940 (`1fdf41c`) — type `EuiSuperSelect` refs as `EuiSuperSelectRef` following the breaking `ref` change in elastic/eui#9972 - elastic#290240 (`54cae3c`) — update tests, page objects, the EUI i18n mapping, and translation files for the removed `euiSelectableListItem.checkedOption` screen-reader text (elastic/eui#9850) - Synced EUI i18n tokens: added `euiKeyboardShortcuts.cmd`, `euiKeyboardShortcuts.copyTitle`, and `euiKeyboardShortcuts.copyDescription` to `i18n_eui_mapping.tsx` and updated the `i18n_service` snapshot ## Package updates ### `@elastic/eui` [v122.0.0](https://github.com/elastic/eui/blob/main/packages/eui/changelogs/CHANGELOG_2026.md) - Added Ctrl/Cmd+C support on `EuiDataGrid` to copy the focused cell value when no text is selected ([elastic#9995](elastic/eui#9995)) **Bug fixes** - Fixed `EuiDataGrid` copy/paste shifting body rows one column right of the headers when control columns were present ([elastic#9954](elastic/eui#9954)) **Breaking changes** - Changed the `ref` of `EuiSuperSelect` from the class instance to an `EuiSuperSelectRef` object, which exposes `openPopover()` and `closePopover()` ([elastic#9972](elastic/eui#9972)) **Accessibility** - Improved the accessibility of `EuiSelectable` by removing redundant "Checked option." screen-reader text (checked state is already conveyed via `aria-checked`/`aria-selected`) ([elastic#9850](elastic/eui#9850)) - Improved the accessibility of `EuiSelectable` and `EuiComboBox` by moving the `title` attribute to the inner text element, preventing duplicate screen-reader announcements of option names ([elastic#9850](elastic/eui#9850)) ### `@elastic/eui-illustrations` [v1.1.0](https://github.com/elastic/eui/blob/main/packages/illustrations/changelogs/CHANGELOG_2026.md) - Added `attachments`, `detection`, `discovery`, `fieldExtraction`, `generatePreview`, `knowledgeIndicator`, `noData`, `processorsError`, `processorsLoading`, and `processorsPreview` illustrations ([elastic#10001](elastic/eui#10001)) ### `@elastic/eui-test-helpers` [v1.7.0](https://github.com/elastic/eui/blob/main/packages/test-helpers/changelogs/CHANGELOG_2026.md) - Added `EuiTreeViewObject`, a Playwright Component Object for `EuiTreeView` ([elastic#10025](elastic/eui#10025)) - Added `EuiToolTipObject`, a Playwright Component Object for `EuiToolTip` ([elastic#10026](elastic/eui#10026)) - Added `EuiContextMenuObject`, a Playwright Component Object for `EuiContextMenu` ([elastic#10013](elastic/eui#10013)) - Added `EuiColorPickerObject`, a Playwright Component Object for `EuiColorPicker` ([elastic#10020](elastic/eui#10020)) **Bug fixes** - Fixed Component Objects not finding components whose `data-test-subj` holds several space-separated tokens, such as `EuiColorPicker`. The root now matches one token, following Kibana's `data-test-subj` convention ([elastic#10015](elastic/eui#10015)) --------- Co-authored-by: Weronika Olejniczak <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Alexey Antonov <[email protected]> Co-authored-by: Lene Gadewoll <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Weronika Olejniczak <[email protected]> Co-authored-by: Weronika Olejniczak <[email protected]> Co-authored-by: Cursor <[email protected]>
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.openPopover()/closePopover()API available on the componentrefviaforwardRefanduseImperativeHandle, typed by the new exportedEuiSuperSelectRef.EuiPortalpattern) so a fast post-mount interaction can't lose the deferred focus callback.Fixes #9485.
API Changes
EuiSuperSelectrefEuiSuperSelectRefobject exposingopenPopover()andclosePopover(). Runtime calls are unchanged; TS consumers typing the ref asEuiSuperSelect<T>need to switch toEuiSuperSelectRef.EuiSuperSelectEuiSuperSelectRefEuiSuperSelectKnown downstream update (type-only) in Kibana:
alerts_solution_selector.tsx—forwardRef<EuiSuperSelect<RuleTypeSolution>, …>→forwardRef<EuiSuperSelectRef, …>config_editor_content.tsx—useRef<EuiSuperSelect<RuleTypeSolution>>(null)→useRef<EuiSuperSelectRef>(null)Screenshots
Not applicable. This is an implementation-only refactor with no intended visual or DOM changes; all 13 focused snapshots remain unchanged.
Impact Assessment
reftype changed from the class instance toEuiSuperSelectRef. Runtime usage (ref.current.openPopover()) is unaffected.@ts-expect-errorcomments moved to the prop diagnostics emitted for a function component. Added a Jest test for the imperative ref. Runtime assertions and snapshots are otherwise unchanged.Impact level: 🟡 Medium
Kibana PR: elastic/kibana#288940
Release Readiness
Documentation: Not applicable; no prop or behavior change.Figma: Not applicable; no visual change.EuiSuperSelect<T>toEuiSuperSelectRef, mirroringEuiFilePickerReffrom [EuiFilePicker] Migrate from class to function component #9879.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 test-staged: 369 suites, 5,318 tests, and 2,759 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 props, DOM snapshots, and browser behavior.QA: No documentation changes.EuiSuperSelect. No VRT was run locally because there is no visual change.changelogs/upcoming/9972.mddocumenting the ref type change.Reviewer checklist