Repository navigation
fix: finish Sheet exit once the scroll rests at the exit position #10835
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 all commits
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 |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import {Button} from '../src/Button'; | ||
| import {expect, it} from 'vitest'; | ||
| import {Heading} from '../src/Heading'; | ||
| import {page, userEvent} from 'vitest/browser'; | ||
| import React from 'react'; | ||
| import {render} from 'vitest-browser-react'; | ||
| import {Sheet, SheetContent, SheetOverlay, SheetTrigger} from '../src/Sheet'; | ||
|
|
||
| function SheetExample() { | ||
| return ( | ||
| <SheetTrigger> | ||
| <Button>Open sheet</Button> | ||
| <SheetOverlay> | ||
| <Sheet style={{height: 200, background: 'white'}}> | ||
| <SheetContent> | ||
| <Heading slot="title">Sheet title</Heading> | ||
| </SheetContent> | ||
| </Sheet> | ||
| </SheetOverlay> | ||
| </SheetTrigger> | ||
| ); | ||
| } | ||
|
|
||
| it('finishes closing once the exit scroll ends, even if the sheet is never reported hidden', async () => { | ||
| // Drop the observer's report that the sheet has left the viewport. | ||
|
Member
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. ok yeah, so this is what i was concerned about, if we have to forcibly drop this, then we don't yet have enough information. We need more research done on why it would be dropped in your CI.
Author
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. Agreed, without a root cause this isn't worth adding. I'll close this for now and reopen if I find out why it's dropped on our CI. |
||
| let NativeIntersectionObserver = window.IntersectionObserver; | ||
| window.IntersectionObserver = class extends NativeIntersectionObserver { | ||
| constructor(callback: IntersectionObserverCallback, options?: IntersectionObserverInit) { | ||
| super((entries, observer) => { | ||
| if (entries.every(entry => entry.intersectionRatio > 0)) { | ||
| callback(entries, observer); | ||
| } | ||
| }, options); | ||
| } | ||
| }; | ||
|
|
||
| try { | ||
| await render(<SheetExample />); | ||
| await userEvent.click(page.getByRole('button', {name: 'Open sheet'})); | ||
| // The dialog is focused once the sheet has entered. | ||
| let dialog = page.getByRole('dialog').element(); | ||
| await expect.poll(() => document.activeElement).toBe(dialog); | ||
|
|
||
| await userEvent.keyboard('{Escape}'); | ||
| await expect.poll(() => document.querySelector('[role="dialog"]')).toBeNull(); | ||
| } finally { | ||
| window.IntersectionObserver = NativeIntersectionObserver; | ||
| } | ||
| }); | ||
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.
for easier reading, please move this declaration before where it is used
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.
Moved it up.