Skip to content

Conversation

@tsullivan
Copy link
Member

@tsullivan tsullivan commented Nov 5, 2025

Summary

Closes #9173
Re-closes https://github.com/elastic/kibana-team/issues/2060

The EUI Flyout System was reverted a short time ago because of a blocking performance issue. This PR restores the feature and introduces a fix for the performance bug. The details of the performance bug fix are below.

This fix can be tested in a Kibana draft PR: elastic/kibana#233806.
Run gh pr checkout 233806

Why are we making this change?

Restoring a feature that had to be temporarily pulled out of EUI, and including a performance fix to resolve the issue that caused it to be reverted.

Performance improvement #

The previous implementation had inefficient code for adding the window resize event listeners: there was a circular dependency problem in src/components/flyout/manager/layout_mode.ts:

  1. An event listener attaches to window resize events and updates the windowWidth state variable
  2. A useEffect recalculates the layout mode and calls the reducer setMode action, which updates the Flyout Manger's state
  3. The state update causes the Flyout Manager provider to re-create its context
  4. setMode would be re-created because it depends on context
  5. Because it depends on setMode, the useEffect triggers again and performs the layout mode calculation: this is a return back to Step 2 -> INFINITE LOOP

The fix was to refactor code to depend on stable references rather than the entire context. Primarily: the setMode callback now just depends on dispatch, which never changes. Secondarily, the large useEffect was broken up to re-run only when the specific values we care about are changed.

  • Profile taken from Kibana before the fix
    page becomes unresponsive after brief window resizing:
    image
  • Profile testing the same use case after the fix
    page stays responsive after extensive window resizing:
    image

NOTE: after the fix, when testing in Kibana, we still see the "JS Event Listeners" metric go up in Kibana after window resize, but this doesn't happen when testing the EUI storybook in isolation.

Screenshots #

The original EUI Flyout System screenshots can be found in #9068 (comment)

Impact to users

The original "Impact to users" and description of the breaking change can be found in #9068 (comment)

QA

Remove or strikethrough items that do not apply to your PR.

General checklist

  • Browser QA
    • [ ] Checked in both light and dark modes
    • [ ] Checked in both MacOS and Windows high contrast modes
    • [ ] Checked in mobile
    • [ ] Checked in Chrome, Safari, Edge, and Firefox
    • [ ] Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA
  • Code quality checklist
  • Release checklist
    • [ ] A changelog entry exists and is marked appropriately
    • [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)
    • [ ] If the changes unblock an issue in a different repo, smoke tested carefully (see Testing EUI features in Kibana ahead of time)
  • Designer checklist
    • [ ] If applicable, file an issue to update EUI's Figma library with any corresponding UI changes. (This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)

tsullivan and others added 2 commits November 5, 2025 08:43
Co-authored-by: Clint Andrew Hall <[email protected]>
Co-authored-by: Weronika Olejniczak <[email protected]>
Co-authored-by: Tomasz Kajtoch <[email protected]>
Co-authored-by: Arturo Castillo Delgado <[email protected]>
Co-authored-by: Paulina Shakirova <[email protected]>
Resize listener always runs, but expensive layout calculations only run when needed.
@tsullivan tsullivan force-pushed the feat/flyout-system-ii branch from 3e0d623 to fe52040 Compare November 5, 2025 17:05
@tsullivan tsullivan marked this pull request as ready for review November 5, 2025 18:18
@tsullivan tsullivan requested a review from a team as a code owner November 5, 2025 18:18
@tsullivan tsullivan force-pushed the feat/flyout-system-ii branch from e966888 to 34690cd Compare November 5, 2025 18:45
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@tkajtoch tkajtoch self-requested a review November 7, 2025 17:47
@tkajtoch tkajtoch changed the base branch from main to feat/flyout-system November 7, 2025 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flyout System] Resizing the viewport to switch layout mode mode freezes the whole tab

3 participants