Skip to content

[EuiDelayRender] Migrate from class to function component - #9949

Merged
weronikaolejniczak merged 1 commit into
elastic:mainfrom
Neilblaze:delay-render-fc
Aug 25, 2026
Merged

[EuiDelayRender] Migrate from class to function component#9949
weronikaolejniczak merged 1 commit into
elastic:mainfrom
Neilblaze:delay-render-fc

Conversation

@Neilblaze

@Neilblaze Neilblaze commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #9501

Converts EuiDelayRender from a class to a function component. The shouldComponentUpdate render gating becomes conditional rendering in the function body, and timer management moves to useEffect, as suggested in the issue's migration notes.

Behavior is preserved: children stay hidden on mount and are hidden again whenever they update, with repeated updates restarting the timer, so content only appears once updates have stopped for the configured delay. Two details worth calling out for review:

  • Hiding updated children happens during the render phase (the documented storing information from previous renders pattern) rather than in the effect. Waiting for an effect would briefly commit updated children before hiding them again, flashing the content and triggering any aria-live announcements it may contain. That matters because the main internal consumer is the screen reader caption in EuiBasicTable. A dedicated test guards this and fails if the hide is moved into the effect.
  • One intentional refinement: re-renders with referentially unchanged children no longer restart the delay, matching the React.memo semantics the issue suggests. The old class re-hid on every parent re-render because its shouldComponentUpdate never inspected props. All in-repo consumers pass fresh JSX children on every render, so nothing changes for them.

The component had no unit tests, so this adds a suite locking in the timing behavior. It was written against the class implementation first, and everything passes on the old class too except the unchanged children case described above.

delay becomes optional in the props type now that static defaultProps is gone. The runtime default of 500ms is unchanged.

API Changes

component / parent prop / child change description
EuiDelayRender delay Type Now optional in EuiDelayRenderProps (was required and filled by defaultProps). Runtime default of 500ms is unchanged

Impact Assessment

Internal refactor with no markup, class name, or styling changes. The only behavior difference is the unchanged children case above, which no known consumer relies on.

Impact level: 🟢 Low

Like the other migrations in this effort (#9860, #9879, #9831) this skips a changelog entry, so it needs the skip-changelog label from a maintainer.

QA instructions for reviewer

  • Open the EuiDelayRender playground in Storybook.
    • The spinner appears only after the configured delay.
    • Changing args re-runs the delay before the spinner reappears.
    • The Cypress a11y spec (delay_render.a11y.tsx) passes.

Behavior is preserved: children stay hidden for the delay duration
on mount and again whenever they update, with repeated updates
restarting the timer. The one refinement is that re-renders with
referentially unchanged children no longer re-trigger the delay,
matching the React.memo semantics suggested in issue elastic#9501. Adds
unit tests locking in the timing behavior.
@Neilblaze
Neilblaze requested a review from a team as a code owner August 24, 2026 14:24
@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 Aug 24, 2026
@Neilblaze

Copy link
Copy Markdown
Contributor Author

CC'ing: @weronikaolejniczak for further visibility.

@Neilblaze

Copy link
Copy Markdown
Contributor Author

cla/check

@weronikaolejniczak weronikaolejniczak added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label Aug 25, 2026
@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

@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 🟢 Thank you for contributing, @Neilblaze 🙏🏻

@weronikaolejniczak
weronikaolejniczak merged commit 66c7b67 into elastic:main Aug 25, 2026
10 of 11 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.

[EuiDelayRender] Migrate from class to function component

2 participants