Skip to content

feat(web): rewrite with vendored vaul, add full event + stacking parity#639

Merged
lodev09 merged 63 commits intomainfrom
feat/web-renderer
Apr 28, 2026
Merged

feat(web): rewrite with vendored vaul, add full event + stacking parity#639
lodev09 merged 63 commits intomainfrom
feat/web-renderer

Conversation

@lodev09
Copy link
Copy Markdown
Owner

@lodev09 lodev09 commented Apr 4, 2026

Summary

Rewrite the web implementation for near-parity with native. Drop @gorhom/bottom-sheet, vendor vaul (v1.1.2, fork of emilkowalski/vaul — upstream is unmaintained) into src/web/vaul/, and extend it to match TrueSheet's API.

Key changes

New web features:

  • Full event lifecycle: onMount, onWill/DidPresent, onWill/DidDismiss, onDetentChange, onDragBegin/Change/End, onPositionChange, onWill/DidFocus, onWill/DidBlur
  • Sheet stacking with cascade translation (mirrors native behavior)
  • detached floating mode with detachedOffset
  • auto detent sized to content
  • Scrollable content + scrollingExpandsSheet
  • Honors elevation, cornerRadius, maxContentHeight, draggable, dismissible, dimmedDetentIndex, insetAdjustment, initialDetentAnimated, anchor/anchorOffset, maxContentWidth

onPositionChange: interpolated index and detent match native, with dual-range mapping so drag-overshoot below the lowest detent reports [-1, 0].

Provider API: useTrueSheet() hook for name-based imperative control; TrueSheetProvider scopes its portal container so sheets unmount with the provider (clean navigation unmount).

Breaking changes

  • Removed stackBehavior prop — stacking is automatic now (cascade animation mirrors native).
  • Peer dep: @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):

  • onPositionChange hook with event-driven RAF (transitionrun/end, animationstart/end)
  • detached / detachedOffset / detachedRadius / detachedWrapperStyle props
  • maxContentHeight ceiling for full + auto detents
  • initialAnimated (skips transition on first snap)
  • 'auto' snap point resolved via ResizeObserver on a flow-root wrapper
  • Pointer-events restored correctly when sheet is hidden by ancestor (React Navigation display: none screens)

External runtime dep: @radix-ui/react-dialog.

Test plan

  • Web: verified present/dismiss, drag, stacking, detached, auto detent, scrollable
  • Web: event lifecycle fires in correct order
  • iOS: verify untouched (entry point is .web.tsx)
  • Android: verify untouched

Checklist

  • iOS tested
  • Android tested
  • Web tested
  • Docs updated (guides/web, guides/stacking, reference/01-configuration, reference/04-types)
  • Changelog entry

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-native-true-sheet Ready Ready Preview, Comment Apr 28, 2026 11:59am

Request Review

lodev09 added 5 commits April 14, 2026 01:42
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.
@github-actions
Copy link
Copy Markdown

Hey @lodev09, this PR is missing a changelog entry.

Add the following under the Unreleased section in CHANGELOG.md:

- **platform**: Description. ([#639](https://github.com/lodev09/react-native-true-sheet/pull/639) by [@lodev09](https://github.com/lodev09))

See CONTRIBUTING.md for more details.

lodev09 added 6 commits April 18, 2026 09:02
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.
lodev09 added 2 commits April 22, 2026 01:52
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.
@lodev09 lodev09 changed the title feat(web): pluggable web renderer with vaul support feat(web): rewrite with vendored vaul, add full event + stacking parity Apr 24, 2026
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.
@lodev09 lodev09 marked this pull request as ready for review April 28, 2026 11:59
@lodev09 lodev09 merged commit 4ce93dd into main Apr 28, 2026
6 checks passed
@lodev09 lodev09 deleted the feat/web-renderer branch April 28, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant