Repository navigation
RAC Sheet Q&A
#10773
Replies: 2 comments 1 reply
|
I looked at
<SheetOverlay position={isPortrait ? 'bottom' : 'center'} swipeDirection="bottom">If the backdrop still resets with that, it's probably worth an issue with a repro.
|
|
Hi, I also looked through the current Sheet.tsx implementation and the Sheet documentation. I think there are a few important distinctions worth highlighting. 1. Prevent swipe dismissal while preserving backdrop and Escape It looks like this is currently not supported through the public API. In SheetOverlay, preventDismissal is forwarded to ModalOverlay as: The same flag is also used by Sheet to clamp its scroll geometry and prevent swipe-to-dismiss. So preventDismissal controls three behaviors together:
For your use case, I agree that separating these controls would be useful. Something along these lines would provide more flexibility: This would allow swipe dismissal to be disabled without sacrificing the other dismissal mechanisms. I would favor a dedicated swipe-dismissal prop over trying to intercept the underlying scroll behavior externally. 2. Changing position at runtime I think explicitly setting swipeDirection is the first thing worth trying here. In the current implementation, when swipeDirection isn't provided, it is derived from position: These configurations have different scroll geometries and view-timeline ranges. Since the backdrop opacity is synchronized with the sheet's scroll progress, changing the derived swipe configuration could explain the opacity reset. Try keeping the swipe direction explicit and stable: This keeps the swipe direction consistent while changing the sheet placement. I haven't verified this against your exact reproduction, so I'd treat it as a workaround to test rather than a guaranteed fix. If the backdrop still resets after this change, a minimal reproduction would help determine whether the issue is caused by the position-dependent layout geometry itself. 3. Controlling enter/exit animation duration I don't see a documented public API or CSS variable for controlling the Sheet's native scroll animation duration. The implementation uses smooth scrolling to move the internal sheet scroller between its entered and exited positions. Because this is native browser smooth scrolling, its duration is controlled by the browser rather than a configurable CSS animation-duration or transition-duration. Changing the overlay's CSS animation duration therefore won't necessarily affect the actual Sheet entry/exit timing. A configurable duration would be a useful enhancement, but I would avoid patching internal scrolling methods or overriding the internal scroller's behavior, since that could interfere with scroll snapping, gesture synchronization, and the exit lifecycle. Summary My takeaways are: Swipe dismissal: A separate public swipe-dismissal control would be useful. preventDismissal currently disables backdrop and Escape dismissal as well. Runtime positioning: Explicitly setting swipeDirection="bottom" is worth testing to avoid changing the swipe configuration when the position changes. Animation duration: There doesn't appear to be a supported public duration control for the native smooth-scroll animation. Thanks for raising these questions. I think all three are useful areas for improving the flexibility of the new Sheet API, particularly for responsive layouts that need to preserve mounted content such as iframes. |
Uh oh!
There was an error while loading. Please reload this page.
I've been experimenting using the new
Sheetfor a single instance that should survive orientation changes (e.g. tablet portrait → landscape) so inner content (including iframes) isn't remounted. In my experimentation screen in portrait mode usesposition="bottom"landscape usesposition="center".A few questions / findings:
1. Prevent scroll-to-dismiss but keep backdrop dismiss
For a centered sheet, swipe-to-dismiss feels a bit unintentional, but clicking the backdrop should still close it.
preventDismissalblocks swipe, Escape, and outside interaction. Is there a supported way to disable only the scroll/swipe dismiss path while leaving backdrop (and maybe Escape) enabled? If not, would you consider splitting that (e.g. allowSwipeDismiss / isDismissable separately)? This is likely something that can be hacked around in the consumer implementation but I thought it would be worth raising.2. Changing position at runtime hides the backdrop
Changing position between
"bottom"and"center"while the sheet is open makes the swipe-driven backdrop opacity jump to0(sheet content stays open).Is runtime position change a supported use case? If yes, is the intended approach to remount the overlay, keep swipeDirection stable (e.g. position="center" + swipeDirection="bottom"), or something else? Happy to file a more formal issue if this is considered a bug.
3. Controlling enter animation duration
Enter/exit are driven by native smooth scrolling of the sheet scroller, not a CSS animation-duration on the overlay. Is there a recommended/public way to control that timing (API, CSS variable, or documented hook), short of patching
scrollTo?All reactions