feat(web): rewrite with vendored vaul, add full event + stacking parity#639
Merged
feat(web): rewrite with vendored vaul, add full event + stacking parity#639
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Strip to bare present/dismiss with overlay, content, and handle.
Move vaul source into src/web/vaul as the sole web drawer. Remove renderer registry, setWebRenderer, and /gorhom and /vaul subpath exports. Scaffold provider context in TrueSheetProvider.web.tsx for direct implementation.
Drop the src/web/vaul ignore rules from prettier and eslint, run prettier across the directory, and trim the README to basic fork attribution.
|
Hey @lodev09, this PR is missing a changelog entry. Add the following under the Unreleased section in See CONTRIBUTING.md for more details. |
Default to 0 for native parity (always dimmed). Fix vaul's getPercentageDragged to handle fadeFromIndex === 0: at the lowest detent dismiss drag returns null so the default distance-based fade-out applies; all other positions return 0 to stay opaque.
Drive the RAF only while the drawer is actually moving (drag, CSS transition, CSS animation) so idle sheets cost zero frames. Move tracking into Content so listeners live for the drawer element's lifetime, including the close animation before Radix unmounts the portal.
Define TrueSheetMethods and TrueSheetStaticMethods in TrueSheet.types, have the native class and web component implement them. Support the index/animated params on web by controlling vaul's activeSnapPoint. Wire the dimmed prop to vaul's modal, and fix the dim overlay not appearing on non-fade snap presents by firing snapToPoint on every open transition.
When the active snap is below fadeFromIndex the overlay is transparent and we want the sheet to behave as non-modal: clicks reach the content behind the drawer and outside-clicks don't dismiss. Drive this off the current snap index so crossing the fade threshold flips modal behavior without unmounting the overlay.
The overlay-trap effect set `document.body.style.pointerEvents = 'none'` on open but only relied on `useControllableState.onChange` to restore `'auto'` on close. In controlled mode, `onChange` only fires for internal `setIsOpen` calls (click-outside, esc) — an external prop flip (imperative `dismiss()`) never triggered it, leaving body unclickable. Reset in the effect itself when `!isOpen`.
Resolve the 'auto' value to measured content height via a ResizeObserver on an inner wrapper rendered only when 'auto' is in the array. The wrapper uses `display: flow-root` to keep first-child margin-top inside `offsetHeight` instead of collapsing through the wrapper.
Mirrors iOS prefersPageSizing. When false on landscape/tablet, renders a centered floating form-sheet (default width 580, height capped to 90% of window) by reusing the detached mechanic with a computed centering offset.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Rewrite the web implementation for near-parity with native. Drop
@gorhom/bottom-sheet, vendorvaul(v1.1.2, fork of emilkowalski/vaul — upstream is unmaintained) intosrc/web/vaul/, and extend it to matchTrueSheet's API.Key changes
New web features:
onMount,onWill/DidPresent,onWill/DidDismiss,onDetentChange,onDragBegin/Change/End,onPositionChange,onWill/DidFocus,onWill/DidBlurdetachedfloating mode withdetachedOffsetautodetent sized to contentscrollingExpandsSheetelevation,cornerRadius,maxContentHeight,draggable,dismissible,dimmedDetentIndex,insetAdjustment,initialDetentAnimated,anchor/anchorOffset,maxContentWidthonPositionChange: interpolatedindexanddetentmatch native, with dual-range mapping so drag-overshoot below the lowest detent reports[-1, 0].Provider API:
useTrueSheet()hook for name-based imperative control;TrueSheetProviderscopes its portal container so sheets unmount with the provider (clean navigation unmount).Breaking changes
stackBehaviorprop — stacking is automatic now (cascade animation mirrors native).@gorhom/bottom-sheet→@radix-ui/react-dialog(still marked optional for native-only consumers).Vendored vaul
Upstream vaul is unmaintained. Forked at v1.1.2 under
src/web/vaul/with localized modifications (documented inline):onPositionChangehook with event-driven RAF (transitionrun/end, animationstart/end)detached/detachedOffset/detachedRadius/detachedWrapperStylepropsmaxContentHeightceiling for full +autodetentsinitialAnimated(skips transition on first snap)'auto'snap point resolved viaResizeObserveron aflow-rootwrapperdisplay: nonescreens)External runtime dep:
@radix-ui/react-dialog.Test plan
.web.tsx)Checklist
guides/web,guides/stacking,reference/01-configuration,reference/04-types)