Sheet: setting its scroll position while it slides out leaves it open, `data-exiting`, for good
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 54/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react, typescript
调研方向
Start by reading the Sheet exit behavior and the related #10813 scrollend discussion; the issue does not name implementation files or tests. Reproduce the next-frame scrollTop write in the provided example, then trace how the exit scroll and IntersectionObserver interact with scroll snapping. Done means the sheet completes closing after a mid-exit scroll position write and the regression is covered by a test.
由索引模型根据 Issue 内容生成。
描述
Provide a general summary of the issue here
If anything sets the sheet scroller's position while a closing Sheet slides out, even to the value it already has, the slide stops. Early in the slide the sheet snaps back open and never finishes closing: it stays open over the page with data-exiting, blocks clicks on the page, and Escape no longer closes it. Only a reload clears it.
🤔 Expected Behavior?
The sheet finishes closing.
😯 Current Behavior
One write of scroller.scrollTop = scroller.scrollTop at different points after pressing Close (bottom sheet, 390×844; open at scrollTop 844, closed at 0):
| Write after Close | Value written | Result |
|---|---|---|
| none | closes in ~470ms | |
| same tick | 844 | closes |
| next frame | 844 | stuck fully open, data-exiting |
| 50ms | 836 | stuck open (rests at 840) |
| 150ms | 611 | stuck (rests at 801, sheet 76px from the top) |
| 300ms | 172 | closes |
💁 Possible Solution
onExit smooth-scrolls the scroller to the exit position and waits for the IntersectionObserver to report the content off screen (react-aria-sheet-close). Setting the scroll position cancels the smooth scroll in progress. Scroll snapping then rests on the nearest snap point, and when that's the open one, the content never leaves the screen, the observer never reports 0, and the exit never resolves.
One option: while exiting, on scrollend, if the scroller isn't at the exit position, scroll to it again. The scrollend fallback proposed for #10813 (#10870) only resolves when the scroller is already at the exit position, so it wouldn't cover this: here the scroller rests at the open position.
🔦 Context
TanStack Router's scroll restoration triggers this. After each navigation it writes back the saved position of every element that scrolled, and that includes the sheet's scroller. Our mobile navigation menu is a Sheet that closes when you navigate. Whenever the new page renders while the menu is still sliding out (e.g. browser Back with the menu open), the menu gets stuck over the page. We work around it by giving the scroller a data-scroll-restoration-id that changes when the sheet opens or closes, since TanStack has no per-element opt-out (TanStack/router#3413). But any code that sets the scroller's position mid-close does the same thing.
🖥️ Steps to Reproduce
import { useState } from 'react'
import { Button, Sheet, SheetBackdrop, SheetContent, SheetOverlay } from 'react-aria-components'
export function App() {
const [open, setOpen] = useState(false)
return (
<>
<button onClick={() => setOpen(true)}>Open sheet</button>
<SheetOverlay isOpen={open} onOpenChange={setOpen} position="bottom">
<SheetBackdrop />
<Sheet overscrollPadding style={{ background: 'white', width: '100%', height: 'calc(100% - 32px)' }}>
<SheetContent aria-label="Test sheet">
<Button slot="close">Close</Button>
</SheetContent>
</Sheet>
</SheetOverlay>
</>
)
}
- Click Open sheet and wait for it to finish sliding in.
- In the console, close it and set its scroll position on the next frame, the way a router's scroll restoration would:
const scroller = document.querySelector('[data-sheet-scroll]')
document.querySelector('[data-sheet-scroll] button').click()
requestAnimationFrame(() => { scroller.scrollTop = scroller.scrollTop })
- The sheet stays open, the overlay keeps
data-exiting, and the page behind it can't be clicked. Escape does nothing.
Without step 2's write, the sheet closes normally.
Version
react-aria-components 1.22.1, React 19.2.4
What browsers are you seeing the problem on?
Chrome
If other, please specify.
Chromium 152 on macOS; first seen in desktop Chrome at a phone-width window.
What operating system are you using?
macOS
🧢 Your Company/Team
No response
🕷 Tracking Issue
Related: #10813
- 主要语言
- TypeScript
- 星标
- 16k
- 派生
- 1.6k
- 平均合并
- 3 天 9 小时
- 30 天内合并 PR
- 45
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
adobe/react-spectrum 的其他 Issue
-
accessibility bug PreviewTrigger
难度 2/5 1-3 小时 新手友好度 76/100
adobe/react-spectrum#10917 · 1 条评论 ·
维护者通常 1 天内回复
-
S2 quiet Picker menu is always 192px wide: its width calc() has no unit可能已有人在做 @darshpatel1052 于 2 天前认领。 未关闭waiting on author
难度 2/5 1 小时以内 新手友好度 88/100
adobe/react-spectrum#10909 · 3 条评论 ·
维护者通常 1 天内回复
-
DatePicker omits timezone for initially empty fields despite zoned placeholderValue可能已有人在做 @mrlexcoder 于 2 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 68/100
adobe/react-spectrum#10900 · 2 条评论 ·
维护者通常 1 天内回复
-
Separator adds a redundant role="separator" to its default <hr>可能已有人在做 @Janani-bn 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
adobe/react-spectrum#10894 · 2 条评论 ·
维护者通常 1 天内回复
-
ComboBox with selectionMode="multiple": Cmd/Ctrl+A does nothing while the popover is open可能已有人在做 @mangeshraut712 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
adobe/react-spectrum#10866 ·
维护者通常 1 天内回复
查看 adobe/react-spectrum 的全部 Issue
相似的 Issue
-
unwrapDatabaseError masks real DB errors with TypeError: Cannot convert object to primitive value未关闭
难度 2/5 1-3 小时 新手友好度 74/100
NEARBuilders/everything-dev#798 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
vercel-labs/durable-harness#53 ·
维护者通常 1 天内回复
-
[Bug]: Redesign tab bars ignore clicks on Linux: hidden chat layers keep window drag regions可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
experiência: a doc manda subir para o Micro do Supabase, mas não diz que exige plano pago nem quanto custa可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area/docs area/ui enhancement
难度 1/5 1-3 小时 新手友好度 88/100
melgarafael/DeskcommCRM#4098 ·
维护者通常 1 天内回复
-
dependencies platform: ios
难度 1/5 1-3 小时 新手友好度 78/100
software-mansion/react-native-executorch#1617 ·
维护者通常 1 天内回复