Skip to content

[EuiFilterSelectItem] Migrate to function component - #9841

Merged
weronikaolejniczak merged 3 commits into
elastic:mainfrom
HuzaifaAbdulRehman:fix-9489-filter-select-item
Jul 27, 2026
Merged

weronikaolejniczak merged 3 commits into
elastic:mainfrom
HuzaifaAbdulRehman:fix-9489-filter-select-item

Conversation

@HuzaifaAbdulRehman

@HuzaifaAbdulRehman HuzaifaAbdulRehman commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Migrates EuiFilterSelectItem from a class component to a function component using hooks.
  • Replaces withEuiTheme with useEuiTheme.
  • Preserves focus, tooltip, scrolling, ref-forwarding, selection, and truncation behavior.
  • Adds focused RTL coverage for the behavior described in the issue.

Fixes #9489.

API Changes

None. The existing public API and behavior are preserved.

Screenshots

Not applicable. This is an internal refactor with no intended visual changes.

Impact Assessment

  • Test impact - Focused unit tests were added and existing snapshot behavior is preserved.

Impact level: Low

Release Readiness

  • Documentation: Not applicable; there are no API or behavior changes.
  • Figma: Not applicable; there are no visual changes.
  • Migration guide: Not applicable; the public API is unchanged.
  • Adoption plan: Not applicable; this refactors an existing component.

QA instructions for reviewer

  • Run the focused test suite on React 17:
    yarn test-unit src/components/filter_group/filter_select_item.test.tsx --runInBand --react-version=17
  • Run the focused test suite on React 18:
    yarn test-unit src/components/filter_group/filter_select_item.test.tsx --runInBand --react-version=18
  • Confirm the selected, excluded, neutral, disabled, focused, tooltip, ref-forwarding, and truncation tests pass.
  • Confirm yarn tsc --noEmit passes.

Validation completed

  • React 17 focused unit tests: 15 passed.
  • React 18 focused unit tests: 15 passed.
  • Changed-file test run: 9 suites and 131 tests passed.
  • TypeScript: passed.
  • Full lint: 0 errors (existing repository warnings remain).
  • git diff --check: passed.

Checklist before marking Ready for Review

  • Filled out all applicable sections above
  • QA: Broad browser, visual, mobile, keyboard, and screen-reader testing is not applicable because rendered behavior and markup are preserved.
  • QA: CodeSandbox and Kibana testing is not applicable for this internal refactor with no public API or visual changes.
  • QA: No documentation changes.
  • Tests: Added/updated focused Jest coverage
  • Changelog: Skipped per maintainer guidance because this is an internal change
  • Breaking changes: Not applicable.

Reviewer checklist

  • Approved Impact Assessment - Acceptable to merge given the consumer impact.
  • Approved Release Readiness - Docs, Figma, and migration info are sufficient to ship.

@github-actions

Copy link
Copy Markdown

👋 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?

@github-actions github-actions Bot added the community contribution (Don't delete - used for automation) label Jul 23, 2026
@HuzaifaAbdulRehman
HuzaifaAbdulRehman marked this pull request as ready for review July 23, 2026 11:47
@HuzaifaAbdulRehman
HuzaifaAbdulRehman requested a review from a team as a code owner July 23, 2026 11:47
Copilot AI review requested due to automatic review settings July 23, 2026 11:47
@HuzaifaAbdulRehman

Copy link
Copy Markdown
Contributor Author

Hi @weronikaolejniczak, thank you for confirming that #9489 was available for a community contribution.

I’ve completed the implementation and marked this PR ready for review. The CLA and changelog checks are complete, and the focused tests pass on both React 17 and React 18.

When convenient, could you please review it or help route it to the appropriate EUI reviewer? The community Buildkite workflow is currently awaiting approval from an Elastic organization member. Thank you!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates EuiFilterSelectItem from a class component to a hook-based function component, replacing withEuiTheme usage with useEuiTheme, and adds focused RTL coverage to validate preserved behavior for selection, tooltip, focus/scrolling, ref forwarding, disabled state, and truncation.

Changes:

  • Refactored EuiFilterSelectItem to a function component using hooks (useEffect, useRef) and useEuiTheme.
  • Added RTL tests covering selection states, disabled behavior, focus/scrolling, tooltip anchoring rules, ref forwarding, and truncation.
  • Added an upcoming changelog entry for the refactor.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/eui/src/components/filter_group/filter_select_item.tsx Converts the component to hooks and swaps theme HOC usage for useEuiTheme.
packages/eui/src/components/filter_group/filter_select_item.test.tsx Adds/updates RTL tests for key behavioral guarantees (focus/scroll, tooltip, selection states, refs, truncation).
packages/eui/changelogs/upcoming/9841.md Documents the internal refactor in the upcoming changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@weronikaolejniczak

Copy link
Copy Markdown
Contributor

buildkite test this

@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

@HuzaifaAbdulRehman

Copy link
Copy Markdown
Contributor Author

Hi @weronikaolejniczak, all three Buildkite builds have now passed, including the visual regression tests. When convenient, could you please continue the review and apply the skip-changelog label you mentioned earlier? Thank you!

@weronikaolejniczak weronikaolejniczak added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label Jul 23, 2026

@weronikaolejniczak weronikaolejniczak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🟢 This is a great contribution, thank you @HuzaifaAbdulRehman 🙏🏻

I'll leave this unmerged for now. No need to rebase onto main unless there are conflicts. We try to keep our releases scoped.

@weronikaolejniczak
weronikaolejniczak merged commit 02db3b5 into elastic:main Jul 27, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community contribution (Don't delete - used for automation) skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EuiFilterSelectItem] Migrate from class to function component

3 participants