Skip to content

Migrate chrome UI class components to function components#253954

Merged
Dosant merged 7 commits intoelastic:mainfrom
Dosant:d/2026-02-19-chrome-component-migration
Feb 20, 2026
Merged

Migrate chrome UI class components to function components#253954
Dosant merged 7 commits intoelastic:mainfrom
Dosant:d/2026-02-19-chrome-component-migration

Conversation

@Dosant
Copy link
Copy Markdown
Contributor

@Dosant Dosant commented Feb 19, 2026

Part of elastic/kibana-team#2651

Problem / Intent

Several chrome UI components are still class components with manual RxJS subscription management, deprecated defaultProps, and withEuiTheme HOC patterns. Breadcrumb mapping logic is duplicated between classic and project headers, and the hasBeta$ observable pattern is copy-pasted across two components.

Approach

  • Rewrite LoadingIndicator, HeaderBadge, HeaderExtension, and HeaderHelpMenu as function components using hooks (useState, useEffect, useCallback, useObservable, useEuiTheme)
  • Extract shared prepareBreadcrumbs() utility to deduplicate breadcrumb mapping in HeaderBreadcrumbs and project Breadcrumbs
  • Extract useHasAppMenuConfig hook to deduplicate the hasBeta$ observable pattern used in Header and project AppMenu

Notes

  • The prepareBreadcrumbs() extraction fixes a subtle pre-existing bug: when breadcrumbs was empty, isLast was computed against the original empty array length (i === -1, always false) instead of the fallback array. The fallback "Kibana" breadcrumb now correctly receives the last class in its data-test-subj attribute ("breadcrumb first last" instead of "breadcrumb first").

@Dosant Dosant added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:SharedUX Platform AppEx-SharedUX (formerly Global Experience) t// labels Feb 19, 2026
Rewrite LoadingIndicator, HeaderBadge, HeaderExtension, and
HeaderHelpMenu as function components with hooks. Extract shared
breadcrumb mapping into prepareBreadcrumbs utility and duplicate
hasBeta$ observable logic into useHasAppMenuConfig hook. Narrow
BehaviorSubject to Observable in GridLayoutProjectSideNav props.

Closes elastic/kibana-team#2651
@Dosant Dosant force-pushed the d/2026-02-19-chrome-component-migration branch from 3e6664e to 20799a3 Compare February 19, 2026 13:19
@Dosant Dosant marked this pull request as ready for review February 19, 2026 13:20
@Dosant Dosant requested a review from a team as a code owner February 19, 2026 13:20
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #2 / Header QueryTabHeader should render the immutable timeline call out providers
  • [job] [logs] Jest Tests #2 / Header QueryTabHeader should render the unauthorized call out with correct icon

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
core 571 573 +2

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 504.9KB 502.0KB -2.9KB

History

Copy link
Copy Markdown
Member

@kowalczyk-krzysztof kowalczyk-krzysztof left a comment

Choose a reason for hiding this comment

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

LGTM

@Dosant Dosant merged commit 4254cd2 into elastic:main Feb 20, 2026
16 checks passed
Dosant added a commit that referenced this pull request Feb 24, 2026
## Summary

@eokoneyo pointed our new error in console in Discover:

<img width="1688" height="1244" alt="image"
src="https://github.com/user-attachments/assets/f6b734ef-2031-427e-b840-9b0c9a3e347b"
/>

I think the error appeared after
#253954

The change to functional components made React highlight an issue with
the breadcrumb badge unmounting and remounting because of an unstable
reference.

This PR is meant to short-fix this:

- Stabilize breadcrumbs badges append extension content identity so
unrelated extension updates do not recreate the badges mount function.
- Refactor badges stream derivation into small helpers to keep the state
pipeline easier to reason about while preserving behavior.
- Add focused unit tests for `createBreadcrumbsState` identity behavior
on non-badge extension updates, badge updates, and `isFirst`
transitions.

Longer term I hope we migrate to native react extension points -
#221815

## Test plan
- [x] `yarn test:jest
src/core/packages/chrome/browser-internal/src/state/breadcrumbs_state.test.ts`
nreese pushed a commit to nreese/kibana that referenced this pull request Feb 25, 2026
## Summary

@eokoneyo pointed our new error in console in Discover:

<img width="1688" height="1244" alt="image"
src="https://github.com/user-attachments/assets/f6b734ef-2031-427e-b840-9b0c9a3e347b"
/>

I think the error appeared after
elastic#253954

The change to functional components made React highlight an issue with
the breadcrumb badge unmounting and remounting because of an unstable
reference.

This PR is meant to short-fix this:

- Stabilize breadcrumbs badges append extension content identity so
unrelated extension updates do not recreate the badges mount function.
- Refactor badges stream derivation into small helpers to keep the state
pipeline easier to reason about while preserving behavior.
- Add focused unit tests for `createBreadcrumbsState` identity behavior
on non-badge extension updates, badge updates, and `isFirst`
transitions.

Longer term I hope we migrate to native react extension points -
elastic#221815

## Test plan
- [x] `yarn test:jest
src/core/packages/chrome/browser-internal/src/state/breadcrumbs_state.test.ts`
qn895 pushed a commit to qn895/kibana that referenced this pull request Mar 11, 2026
## Summary

@eokoneyo pointed our new error in console in Discover:

<img width="1688" height="1244" alt="image"
src="https://github.com/user-attachments/assets/f6b734ef-2031-427e-b840-9b0c9a3e347b"
/>

I think the error appeared after
elastic#253954

The change to functional components made React highlight an issue with
the breadcrumb badge unmounting and remounting because of an unstable
reference.

This PR is meant to short-fix this:

- Stabilize breadcrumbs badges append extension content identity so
unrelated extension updates do not recreate the badges mount function.
- Refactor badges stream derivation into small helpers to keep the state
pipeline easier to reason about while preserving behavior.
- Add focused unit tests for `createBreadcrumbsState` identity behavior
on non-badge extension updates, badge updates, and `isFirst`
transitions.

Longer term I hope we migrate to native react extension points -
elastic#221815

## Test plan
- [x] `yarn test:jest
src/core/packages/chrome/browser-internal/src/state/breadcrumbs_state.test.ts`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Platform AppEx-SharedUX (formerly Global Experience) t// v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants