Skip to content

refactor!: derive auto detent from container's yoga layout#745

Closed
lodev09 wants to merge 2 commits into
v4from
refactor/container-auto-detent
Closed

refactor!: derive auto detent from container's yoga layout#745
lodev09 wants to merge 2 commits into
v4from
refactor/container-auto-detent

Conversation

@lodev09

@lodev09 lodev09 commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

The container is now a plain yoga flex column (header, content, footer) whose natural height is the auto detent — replacing the contentHeight + headerHeight summing on all platforms. Yoga itself decides what counts: in-flow header/footer take layout space and count; floating (position: 'absolute') ones overlay and don't. Full layout parity with hand-rolled views — the header/footer props are now purely behavior slots (edge effects, keyboard handling, a11y).

Breaking changes

  • Footer is in-flow by default — it sits below the content (content's flex: 1 pushes it to the sheet's bottom edge) instead of overlaying it, counts toward auto, and pinned scrollables shrink to make room for it (no more manual paddingBottom compensation). Float it via footerStyle (position: 'absolute') to restore the overlay behavior.
  • Floating headers no longer inflate auto/peek heights — previously a headerStyle with position: 'absolute' still added its height to the auto detent, which was visually incorrect.
  • With auto detents the container is content-sized, so floated children pin to the content's box — the same thing a hand-rolled absolute view would do.

Implementation

  • TrueSheetContainerView gets a custom shadow node/state (interfaceOnly): sizes naturally for auto, fills the sheet when a ScrollView is pinned (mirrors the content's bounded state via delegate)
  • autoHeight = container height + pinned ScrollView content delta, measured on the container — one formula, valid in both regimes; headerHeight/contentHeight plumbing deleted everywhere
  • peek derives from the container-relative peek extent + footer height; without a TrueSheetPeek it falls back to the content's layout offset (collapse-to-header preserved)
  • Android positionFooter reduced from per-frame y-pinning to a pure keyboard translationY slide (parity with iOS) — yoga owns the footer's frame now
  • Web: footer renders in the drawer flow instead of vaul's detachedSiblings float; vaul's auto-size wrapper is now position: relative so floated children get native-equivalent containing-block semantics
  • Detent invalidation is skipped when all detents are fractional (the container lays out on every sheet resize now)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Test Plan

  • yarn typecheck, yarn lint, yarn test (44 passing), objc/ktlint clean
  • Pending on-device verification (iOS/Android/Web): auto detent with in-flow/floating header and footer, auto + scrollables, peek with/without TrueSheetPeek, footer keyboard slide, drag tracking

Screenshots / Videos

Checklist

  • I tested on iOS
  • I tested on Android
  • I tested on Web
  • I updated the documentation (if needed)
  • I added a changelog entry (if needed)

🤖 Generated with Claude Code

lodev09 added 2 commits July 17, 2026 07:11
The container is now a plain flex column (header, content, footer) whose
natural height IS the auto detent — floating (absolute) header/footer are
excluded by yoga itself, no more header/content height summing.

- Footer is in-flow by default (content flex pushes it to the bottom);
  float via footerStyle. Pinned scrollables shrink to make room for it
- Container gets a custom shadow node/state: fills the sheet when a
  ScrollView is pinned, sizes naturally otherwise
- autoHeight = container height + pinned ScrollView content delta,
  measured on the container (headerHeight/contentHeight plumbing removed)
- Peek derives from the container-relative peek extent + footer height
- Android footer keyboard shift is now a pure translation (parity w/ iOS)
- Skip detent invalidation when detents are all fractional
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

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 Jul 16, 2026 11:55pm

Request Review

@lodev09
lodev09 changed the base branch from main to v4 July 17, 2026 17:56
@lodev09 lodev09 closed this Jul 17, 2026
@lodev09
lodev09 deleted the refactor/container-auto-detent branch July 17, 2026 18:46
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