-
Notifications
You must be signed in to change notification settings - Fork 873
[Flyout] use container as reference for pushMinBreakpoint #9592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tsullivan
merged 14 commits into
elastic:main
from
tsullivan:flyout/container-prop-and-pushMinBreakpoint
Apr 23, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c29278d
initial pass on making push-vs-overlay decision based on the containeβ¦
tsullivan 8a225a4
fix lint
tsullivan 1662d6d
Merge branch 'main' into flyout/container-prop-and-pushMinBreakpoint
tsullivan 281ee82
add changelog
tsullivan 5ad0270
fix the duplicate ResizeObserver
tsullivan d253c1a
use state.referenceWidth from the manager - the single source of trutβ¦
tsullivan d1cd087
fix comment over-verbosity
tsullivan b0f36af
flyout component hooks test
tsullivan 70df052
fix lint
tsullivan 3b25637
Merge branch 'main' into flyout/container-prop-and-pushMinBreakpoint
tsullivan 63f4636
Merge branch 'main' into flyout/container-prop-and-pushMinBreakpoint
tsullivan aa3ce4c
Merge branch 'flyout/container-prop-and-pushMinBreakpoint' of github.β¦
tsullivan d1ab8d3
add guard against theme lacking requested breakpoint key
tsullivan 7227438
update changelog with more descriptive wording
tsullivan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| **Bug fixes** | ||
|
|
||
| - Fixed `EuiFlyout` to compare `pushMinBreakpoint` against the container's width, instead of the viewport width, when the `container` prop is provided. This ensures app-scoped flyouts switch between push and overlay modes based on the space actually available inside their container. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import { renderHook } from '../../test/rtl/render_hook'; | ||
| import { useIsPushed } from './hooks'; | ||
|
|
||
| // Mock the viewport-based breakpoint hook so tests can control it | ||
| // independently of the jsdom window size. | ||
| jest.mock('../../services', () => { | ||
| const actual = jest.requireActual('../../services'); | ||
| return { | ||
| ...actual, | ||
| useIsWithinMinBreakpoint: jest.fn(() => false), | ||
| }; | ||
| }); | ||
|
|
||
| const mockUseIsWithinMinBreakpoint = jest.requireMock('../../services') | ||
| .useIsWithinMinBreakpoint as jest.Mock; | ||
|
|
||
| describe('useIsPushed', () => { | ||
| beforeEach(() => { | ||
| mockUseIsWithinMinBreakpoint.mockReset().mockReturnValue(false); | ||
| }); | ||
|
|
||
| describe('viewport fallback (no containerWidth)', () => { | ||
| it('returns true when type is push and viewport is large enough', () => { | ||
| mockUseIsWithinMinBreakpoint.mockReturnValue(true); | ||
| const { result } = renderHook(() => | ||
| useIsPushed({ type: 'push', pushMinBreakpoint: 'm' }) | ||
| ); | ||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it('returns false when viewport is too small', () => { | ||
| mockUseIsWithinMinBreakpoint.mockReturnValue(false); | ||
| const { result } = renderHook(() => | ||
| useIsPushed({ type: 'push', pushMinBreakpoint: 'm' }) | ||
| ); | ||
| expect(result.current).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('container width', () => { | ||
| it('returns true when container width exceeds breakpoint', () => { | ||
| // Viewport mock returns false β should be ignored | ||
| mockUseIsWithinMinBreakpoint.mockReturnValue(false); | ||
| const { result } = renderHook(() => | ||
| useIsPushed({ | ||
| type: 'push', | ||
| pushMinBreakpoint: 'm', | ||
| containerWidth: 800, // > 768 | ||
| }) | ||
| ); | ||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it('returns false when container width is below breakpoint', () => { | ||
| // Viewport mock returns true β should be ignored | ||
| mockUseIsWithinMinBreakpoint.mockReturnValue(true); | ||
| const { result } = renderHook(() => | ||
| useIsPushed({ | ||
| type: 'push', | ||
| pushMinBreakpoint: 'm', | ||
| containerWidth: 700, // < 768 | ||
| }) | ||
| ); | ||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it('returns true when container width equals breakpoint exactly', () => { | ||
| const { result } = renderHook(() => | ||
| useIsPushed({ | ||
| type: 'push', | ||
| pushMinBreakpoint: 'm', | ||
| containerWidth: 768, // === 768 | ||
| }) | ||
| ); | ||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it('falls back to the viewport hook when the breakpoint key is not on the theme', () => { | ||
| mockUseIsWithinMinBreakpoint.mockReturnValue(true); | ||
| const { result } = renderHook(() => | ||
| useIsPushed({ | ||
| type: 'push', | ||
| pushMinBreakpoint: 'xxl', // not a default theme key | ||
| containerWidth: 2000, | ||
| }) | ||
| ); | ||
| expect(result.current).toBe(true); | ||
| expect(mockUseIsWithinMinBreakpoint).toHaveBeenCalledWith('xxl'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('non-push type', () => { | ||
| it('returns false for overlay type regardless of containerWidth', () => { | ||
| const { result } = renderHook(() => | ||
| useIsPushed({ | ||
| type: 'overlay', | ||
| pushMinBreakpoint: 'm', | ||
| containerWidth: 1200, | ||
| }) | ||
| ); | ||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it('returns false for overlay type regardless of viewport', () => { | ||
| mockUseIsWithinMinBreakpoint.mockReturnValue(true); | ||
| const { result } = renderHook(() => | ||
| useIsPushed({ type: 'overlay', pushMinBreakpoint: 'm' }) | ||
| ); | ||
| expect(result.current).toBe(false); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.