Skip to content

[EuiFlyoutMenu] Add pagination controls with previous/next buttons and counter - #9722

Merged
paulinashakirova merged 8 commits into
elastic:mainfrom
paulinashakirova:flyout-pagination
Jun 18, 2026
Merged

paulinashakirova merged 8 commits into
elastic:mainfrom
paulinashakirova:flyout-pagination

Conversation

@paulinashakirova

@paulinashakirova paulinashakirova commented Jun 16, 2026 •

Copy link
Copy Markdown

Summary

What: Adds Prev/Next pagination controls to EuiFlyoutMenu — the menu bar rendered at the top of every flyout. Two consumption paths are supported:

  1. Prop-based (flyoutMenuProps.pagination) — the caller owns pagination state and passes { currentIndex, total, onPrevious, onNext } directly. Works with both overlay and managed flyouts.
  2. Store-based (getFlyoutManagerStore().setPagination(flyoutId, pagination)) — a separate React root (e.g. a data grid or list mounted independently) pushes pagination state into the flyout manager singleton without needing shared React context. The managed flyout reads and displays it automatically.

Why: A common pattern in complex UIs is a list (table, data grid, search results) paired with a detail flyout — users expect to step through items without closing and reopening the flyout. When list and flyout share a React tree the prop-based path covers this. When they live in separate React roots (e.g. independently mounted micro-frontends or portals), the store-based path lets the list push navigation state into the flyout manager without shared context or prop drilling.
(There is a corresponding Epic on Kibana's side (https://github.com/elastic/kibana-team/issues/3152). Reach out for the link)

How:

  • PaginationControls is an internal component rendered in the left slot of EuiFlyoutMenu. Per the design spec (see image below), the left slot holds either back-button + history or pagination — not both. When pagination.total > 1, pagination takes precedence and the back button is suppressed.
  • The flyout manager store gains a setPagination action/reducer that silently no-ops for unregistered flyout IDs (overlay/unmanaged flyouts receive pagination via the prop instead).
  • EuiManagedFlyout merges both sources with store-wins precedence (storePagination ?? propPagination). Using both simultaneously logs a dev warning.
  • Icons use arrowUp / arrowDown per the design spec (vertical list/data navigation, not horizontal).
  • Counter is visually rendered with aria-hidden="true" and duplicated inside EuiScreenReaderLive for assistive technology.

API Changes

component / parent prop / child change description
EuiFlyoutMenu pagination Added EuiFlyoutMenuPagination — enables Prev/Next controls and a position counter (N of total) in the menu bar
EuiFlyoutMenuPagination — Added (new type) { currentIndex: number, total: number, onPrevious: () => void, onNext: () => void } — zero-based index
FlyoutManagerApi setPagination(flyoutId, pagination) Added Cross-root store API; silent no-op for unmanaged/overlay flyouts
EuiManagedFlyoutState pagination Added Persists pagination state per flyout in the manager store
useFlyoutPagination — Added (new hook, manager/index.ts) Selector hook to read current pagination for a given flyout ID

Screenshots

Screenshot 2026-06-16 at 16 56 43 Screenshot 2026-06-16 at 16 57 06
Before After
No navigation controls in flyout menu bar Prev ↑ / N of total / Next ↓ in the menu bar left slot

Impact Assessment

  • 🔴 Breaking changes — None. All new API surface; existing flyouts are unaffected.
  • 💅 Visual changes — New UI elements appear only when pagination prop is provided or setPagination is called. No change to existing flyout appearance.
  • 🧪 Test impact — New Jest tests added for EuiFlyoutMenu (pagination block), reducer, store, and selectors. Snapshot baseline unchanged for existing tests.
  • 🔧 Hard to integrate — No changes are required to adopt; the store API is additive.

Impact level: 🟢 Low — purely additive, no changes to existing rendered output.

Release Readiness

  • Documentation: Covered by Storybook stories — "Pagination (prop-based)" in EuiFlyoutMenu and "Cross-root pagination" in Flyout Manager.
  • Design: Follows existing flyout-menu design spec.
  • Migration guide: N/A — no breaking changes or deprecations.
  • Adoption plan: Targets any list-plus-detail-flyout pattern. The store-based setPagination API is designed for consumers where the list and flyout live in separate React roots.

QA instructions for reviewer

Prop-based pagination — Storybook: Layout > EuiFlyout > EuiFlyoutMenu > Pagination (prop-based)

  • Prev (↑) button is disabled on the first item; Next (↓) button is disabled on the last item.
  • Clicking Prev/Next updates the counter (N of 5) and the flyout body content.
  • A screen reader announces the counter on each navigation (use VoiceOver or NVDA — should announce once, not twice).
  • The back button is not rendered when pagination is active.
  • No pagination controls appear when total ≤ 1.

Store-based / cross-root pagination — Storybook: Layout > EuiFlyout > Flyout Manager > Cross-root pagination

  • The "Data grid (separate React root)" rows and the flyout menu bar Prev/Next stay in sync.
  • Clicking a row in the data grid updates the flyout body to the corresponding item and moves the counter.
  • Using Prev/Next in the flyout menu bar updates the flyout body (the onPrevious/onNext callbacks update the data grid root's currentIndex, which re-calls setPagination).
  • Closing and re-opening the flyout resets cleanly (no stale pagination state).

Keyboard / accessibility

  • Both Prev and Next buttons are reachable and activatable by keyboard.
  • When at the first or last item, the corresponding navigation button is visually disabled and removed from the tab order.
  • Counter is not double-announced.

Checklist before marking Ready for Review

  • Filled out all sections above
  • QA: Tested light/dark modes, high contrast, mobile, Chrome/Safari/Firefox, keyboard-only, screen reader
  • QA: Tested in ~~CodeSandbox~ (new API surface — testable post-publish) and Kibana
  • QA: Tested docs changes
  • Tests: Added/updated Jest tests (pagination in flyout_menu.test.tsx, reducer, store, selectors)
  • Changelog: Added changelog entry (packages/eui/changelogs/upcoming/9722.md)
  • Breaking changes: N/A

Reviewer checklist

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

Design

Screenshot 2026-06-16 at 22 18 12

@paulinashakirova paulinashakirova self-assigned this Jun 16, 2026
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
2 visual difference(s) found - expand to review, then click Approve visual changes to update baselines

euipopover (1 difference)

StoryBeforeAfterDiff
playground desktop

euidatagrid (1 difference)

StoryBeforeAfterDiff
additional controls options desktop

…n naming

- Added `pagination` prop to `EuiFlyoutMenuProps` for Prev/Next navigation and position counter.
- Implemented `setPagination(flyoutId, pagination)` in the flyout manager store for reactive updates.
- Created `useFlyoutPagination(flyoutId)` hook for accessing pagination overrides.
- Renamed `onPrev` to `onPrevious` in relevant components and tests for consistency.

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

Adds pagination (Prev/Next + counter) to the EuiFlyoutMenu menu bar and enables cross-root pagination updates for managed flyouts via the flyout manager store API.

Changes:

  • Added EuiFlyoutMenuProps.pagination / EuiFlyoutMenuPagination and rendered pagination controls (Prev/Next + N of total) when total > 1.
  • Extended the flyout manager store with setPagination, reducer support, and a useFlyoutPagination selector hook; EuiManagedFlyout merges store + prop pagination with store precedence and a dev warning when both are set.
  • Added Storybook examples, Jest tests, and a changelog entry for the new API.

Reviewed changes

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

Show a summary per file
File Description
packages/eui/src/components/flyout/use_flyout_menu.ts Treats pagination (total > 1) as menu “content” for auto-render decisions.
packages/eui/src/components/flyout/manager/types.ts Adds pagination to managed flyout state and setPagination to the manager API typing.
packages/eui/src/components/flyout/manager/store.ts Wires setPagination store method to dispatch the new action.
packages/eui/src/components/flyout/manager/store.test.ts Adds store tests ensuring setPagination updates state and subscriber notifications behave as expected.
packages/eui/src/components/flyout/manager/selectors.ts Adds useFlyoutPagination selector hook.
packages/eui/src/components/flyout/manager/reducer.ts Implements ACTION_SET_PAGINATION reducer behavior (no-op on missing flyout or same ref).
packages/eui/src/components/flyout/manager/reducer.test.ts Adds reducer coverage for setting/clearing/no-op pagination.
packages/eui/src/components/flyout/manager/index.ts Re-exports the new action creator and selector hook.
packages/eui/src/components/flyout/manager/hooks.ts Re-exports useFlyoutPagination from selectors.
packages/eui/src/components/flyout/manager/flyout_sessions.stories.tsx Adds a cross-root pagination Storybook demo using the singleton store.
packages/eui/src/components/flyout/manager/flyout_managed.tsx Merges store/prop pagination (store wins) and warns once if both are provided.
packages/eui/src/components/flyout/manager/flyout_managed.test.tsx Updates mocks to include useFlyoutPagination.
packages/eui/src/components/flyout/manager/actions.ts Adds ACTION_SET_PAGINATION and the setPagination action creator.
packages/eui/src/components/flyout/manager/mocks/index.ts Extends manager mocks with a setPagination stub.
packages/eui/src/components/flyout/index.ts Re-exports the new EuiFlyoutMenuPagination type from the flyout entrypoint.
packages/eui/src/components/flyout/flyout_menu.tsx Defines pagination types and renders Prev/Next + counter with SR announcements.
packages/eui/src/components/flyout/flyout_menu.test.tsx Adds pagination UI and interaction tests.
packages/eui/src/components/flyout/flyout_menu.styles.ts Adds styling for the pagination counter text.
packages/eui/src/components/flyout/flyout_menu.stories.tsx Adds a prop-based pagination Storybook story for overlay flyouts.
packages/eui/changelogs/upcoming/9722.md Documents the new pagination props/store API and selector hook.
Comments suppressed due to low confidence (1)

packages/eui/src/components/flyout/flyout_menu.tsx:371

  • When pagination is active (pagination.total > 1), the design/PR description says the left slot should show pagination instead of back button + history. The back button is suppressed, but the history popover still renders, so the UI can show pagination and history at the same time.
        {pagination && pagination.total > 1 ? (
          <PaginationControls pagination={pagination} styles={styles} />
        ) : (
          showBackButton && (
            <EuiFlexItem grow={false}>
              <BackButton {...backButtonProps} />
            </EuiFlexItem>
          )
        )}

        {historyItems.length > 0 && (
          <EuiFlexItem grow={false}>
            <HistoryPopover items={historyItems} />
          </EuiFlexItem>
        )}

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

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
3 visual difference(s) found - expand to review, then click Approve visual changes to update baselines

euipopover (1 difference)

StoryBeforeAfterDiff
playground desktop

euidatagrid (2 differences)

StoryBeforeAfterDiff
additional controls options desktop
column selector desktop

- Introduced `pagination` prop to `EuiFlyoutMenuProps` for improved navigation with Previous/Next buttons and a position counter.
- Updated button icons from `arrowUp`/`arrowDown` to `chevronSingleUp`/`chevronSingleDown` for better visual clarity.
- Adjusted aria-labels for accessibility, changing from "Alert details" to "Item details".
- Refactored pagination controls layout for better responsiveness and structure.
- Added console warning for dual pagination sources to prevent confusion.
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
2 visual difference(s) found - expand to review, then click Approve visual changes to update baselines

euipopover (1 difference)

StoryBeforeAfterDiff
playground desktop

euidatagrid (1 difference)

StoryBeforeAfterDiff
additional controls options desktop

- Enhanced `EuiFlyoutMenuProps` with a `pagination` prop for improved navigation, allowing for Previous/Next buttons and a position counter.
- Updated flyout manager to conditionally hide the back button and history items when pagination is active.
- Added a new documentation page for pagination usage in flyouts, including an interactive example.
- Refactored related tests to ensure proper functionality of pagination controls.
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
2 visual difference(s) found - expand to review, then click Approve visual changes to update baselines

euicodeblock (1 difference)

StoryBeforeAfterDiff
virtualized code block scrolling desktop

euidatagrid (1 difference)

StoryBeforeAfterDiff
additional controls options desktop

- Introduced new localization tokens for pagination controls: "Previous", "Next", and a position counter format.
- Updated the i18ntokens.json file to include these new tokens for better internationalization support in the EuiFlyoutMenu component.
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
2 visual difference(s) found - expand to review, then click Approve visual changes to update baselines

euipopover (1 difference)

StoryBeforeAfterDiff
playground desktop

euidatagrid (1 difference)

StoryBeforeAfterDiff
additional controls options desktop

@paulinashakirova
paulinashakirova marked this pull request as ready for review June 16, 2026 20:45
@paulinashakirova
paulinashakirova requested a review from a team as a code owner June 16, 2026 20:45

@tsullivan tsullivan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. This is GREAT!

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.

nit: These changes should be reverted. This file is updated automatically during release.

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

The changes look great! I'm happy to approve when you revert the i18ntokens.json changes! 🎉

@elasticmachine

elasticmachine commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator

💔 Build Failed

Failed CI Steps

History

cc @paulinashakirova

@elasticmachine

Copy link
Copy Markdown
Collaborator

💚 Build Succeeded

History

cc @paulinashakirova

@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
1 visual difference(s) found - expand to review, then click Approve visual changes to update baselines

euidatagrid (1 difference)

StoryBeforeAfterDiff
additional controls options desktop

@paulinashakirova
paulinashakirova merged commit 97efe24 into elastic:main Jun 18, 2026
1 check passed
@paulinashakirova
paulinashakirova deleted the flyout-pagination branch June 18, 2026 09:57
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.

5 participants