Repository navigation
Popover: drop the will-change hint once the popover stops moving #77359
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
Changes from 2 commits
3a37067
870e6eb
67e1482
a375761
c57786d
75c6f4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ import { | |
| placementToMotionAnimationProps, | ||
| } from '../utils'; | ||
| import Popover from '..'; | ||
| // eslint-disable-next-line @wordpress/no-non-module-stylesheet-imports | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @mirka this exception looks necessary, I wonder if there's anything we can do to make this better?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heads up: with #84019 merged, we should be able to remove this disable comment entirely after rebasing.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed in a375761 |
||
| import '../style.scss'; | ||
| import { Provider as SlotFillProvider } from '../../slot-fill'; | ||
| import type { PopoverProps } from '../types'; | ||
| import { PopoverInsideIframeRenderedInExternalSlot } from './utils/index.js'; | ||
|
|
@@ -843,6 +845,57 @@ describe( 'Popover', () => { | |
| } ); | ||
| } ); | ||
|
|
||
| it( 'hints at transform only while it is being repositioned', async () => { | ||
| await render( | ||
| <Popover animate={ false } data-testid="popover-element"> | ||
| Inside popover | ||
| </Popover> | ||
| ); | ||
|
|
||
| const popover = screen.getByTestId( 'popover-element' ); | ||
|
|
||
| // Positioning has just run, so the compositing hint is on. | ||
| expect( getComputedStyle( popover ).willChange ).toBe( 'transform' ); | ||
|
|
||
| // Once the popover settles, the hint is dropped so the popover stops | ||
| // occupying a compositing layer of its own, which is what makes | ||
| // Chrome render it blurry. | ||
| await waitFor( () => | ||
| expect( getComputedStyle( popover ).willChange ).toBe( 'auto' ) | ||
| ); | ||
| } ); | ||
|
|
||
| it( 'drops the transform hint when the popover moves into a slot without repositioning', async () => { | ||
| const Test = ( { hasSlot }: { hasSlot: boolean } ) => ( | ||
| <SlotFillProvider> | ||
| <Popover animate={ false } data-testid="popover-element"> | ||
| Inside popover | ||
| </Popover> | ||
| { hasSlot && <Popover.Slot /> } | ||
| </SlotFillProvider> | ||
| ); | ||
| const { rerender } = await render( <Test hasSlot={ false } /> ); | ||
|
|
||
| const inlinePopover = screen.getByTestId( 'popover-element' ); | ||
| await waitFor( () => | ||
| expect( getComputedStyle( inlinePopover ).willChange ).toBe( | ||
| 'auto' | ||
| ) | ||
| ); | ||
|
|
||
| // Mounting the slot swaps in a new floating element at the same | ||
| // coordinates, and that one has to lose the hint too. | ||
| await rerender( <Test hasSlot /> ); | ||
|
|
||
| const slottedPopover = screen.getByTestId( 'popover-element' ); | ||
| expect( slottedPopover ).not.toBe( inlinePopover ); | ||
| await waitFor( () => | ||
| expect( getComputedStyle( slottedPopover ).willChange ).toBe( | ||
| 'auto' | ||
| ) | ||
| ); | ||
| } ); | ||
|
|
||
| it( 'should call a consumer-provided onKeyDown alongside close-on-Escape', async () => { | ||
| const user = userEvent.setup(); | ||
| const onClose = vi.fn(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: neither new test moves an already-settled popover, so both still pass if the
x/ydependencies are removed.Could we cover movement after idle, including the hint staying on until movement stops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new test was added in c57786d.