Skip to content

[EuiOutsideClickDetector] Migrate from class to function component - #9667

Merged
weronikaolejniczak merged 2 commits into
elastic:mainfrom
Dmc0125:refactor/outside-click-detector
May 26, 2026
Merged

weronikaolejniczak merged 2 commits into
elastic:mainfrom
Dmc0125:refactor/outside-click-detector

Conversation

@Dmc0125

@Dmc0125 Dmc0125 commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • What: Converted EuiOutsideClickDetector from a class component to a functional component.
  • Why: Fixes [EuiOutsideClickDetector] Migrate from class to function component #9462
  • How:
    • Replaced this.id (initialized in constructor via htmlIdGenerator()()) with useGeneratedHtmlId()
    • Replaced this.capturedDownIds with useRef<string[]>([])
    • Replaced componentDidMount/componentWillUnmount with useEffect

API Changes

component / parent prop / child change description

Screenshots

Before After
{Before image} {After image}

Impact Assessment

Note: Most PRs should be tested in Kibana to help gauge their Impact before merging.

  • 🔴 Breaking changes — What will break? How many usages in Kibana/Cloud UI are impacted?
  • 💅 Visual changes — May impact style overrides; could require visual testing. Explain and estimate impact.
  • 🧪 Test impact — May break functional or snapshot tests (e.g., HTML structure, class names, default values).
  • 🔧 Hard to integrate — If changes require substantial updates to Kibana, please stage the changes and link them here.

Impact level: 🟢 None

Release Readiness

  • Documentation: {link to docs page(s)}
  • Figma: {link to Figma or issue}
  • Migration guide: {steps or link, for breaking/visual changes or deprecations}
  • Adoption plan (new features): {link to issue/doc or outline who will integrate this and where}

QA instructions for reviewer

Checklist before marking Ready for Review

  • Filled out all sections above

Reviewer checklist

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

@Dmc0125
Dmc0125 requested a review from a team as a code owner May 19, 2026 11:18
@github-actions github-actions Bot added the community contribution (Don't delete - used for automation) label May 19, 2026
@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?

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

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 EuiOutsideClickDetector from a React class component to a function component, aligning it with modern hook-based patterns while preserving its outside-click detection behavior used by popovers and other overlays.

Changes:

  • Replaced constructor-generated IDs with useGeneratedHtmlId()
  • Replaced instance state (capturedDownIds) with a useRef and moved document listener setup/teardown to useEffect
  • Refactored child event stamping/handling logic into local functions and continued cloning the single child element with injected handlers

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

@elasticmachine

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

@elasticmachine

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

@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.

I tested it, works well, CI is passing. The Copilot's comment about forwardRef is irrelevant, I checked Kibana and there are no cases of ref being passed to EuiOutsideClickDetector (this is a very simple component).

Thank you for contributing, we highly appreciate it! 🚀

@weronikaolejniczak
weronikaolejniczak merged commit 92e7431 into elastic:main May 26, 2026
1 check 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.

[EuiOutsideClickDetector] Migrate from class to function component

4 participants