Skip to content

Let an h-full drawer child fill the drawer's height - #212

Merged
simonhamp merged 2 commits into
NativePHP:mainfrom
wojt-janowski:fix/drawer-fill-height
Nov 14, 2026
Merged

simonhamp merged 2 commits into
NativePHP:mainfrom
wojt-janowski:fix/drawer-fill-height

Conversation

@wojt-janowski

Copy link
Copy Markdown
Contributor

Closes #113.

Problem

Both drawer hosts put the drawer's children in a scroll view. A scroll view measures its children with an unbounded height, so an h-full root column hugs its content and justify-between has no space to pin a footer ("Sign out", "Settings") to the bottom of the drawer.

Fix

The same rule the scroll-view renderers already use: a direct child with h-full gets the drawer's height as a minimum. Content taller than the drawer still grows and scrolls, and children without h-full are unchanged.

  • Android (NativeLayoutDrawerHost.kt): BoxWithConstraints supplies the drawer height, and only fill-height children get Modifier.heightIn(min = viewport), with their width reproduced, as in ScrollViewRenderer. The patch in the issue gave every child the minimum, which makes a drawer with two children two drawers tall.
  • iOS (NativeUIDrawerHost.swift): a GeometryReader around the ScrollView supplies the panel height, less the top inset the content is padded by, to fill-height children through MinViewportHeightModifier, which is now shared with the scroll-view renderer instead of private.

Test plan

  • Android: new DrawerFillHeightTest opens a modal drawer from its menu button. The h-full root reaches the bottom of the drawer (on main it's 120dp in a 470dp drawer), a sibling without h-full keeps its own height, and a root taller than the drawer still scrolls. Whole tests/android suite passes. Changing the minimum to a fixed height, or giving every child the minimum, each fails a case.
  • iOS: no test target in this repo, so I compiled the real NativeUIDrawerHost.swift in a throwaway Swift package with a stand-in NodeView and laid it out in a 400×800 window on an iPhone 17 Pro / iOS 27.0 simulator. An h-full child measured 20pt on main and 800pt with the fix; a sibling stayed at 20pt.
  • Not checked on a device, and justify-between itself is only exercised through the real renderers, not the stand-ins.
  • The test module now depends on material-icons-core, because the drawer host draws Icons.Filled.Menu.

Both drawer hosts put their children in a scroll view, which measures them with an unbounded height, so an h-full root column hugged its content and justify-between couldn't pin a footer to the bottom. As in the scroll-view renderers, a direct child with h-full now gets the drawer's height as a minimum; taller content still grows and scrolls, and other children are unchanged. Closes NativePHP#113.

Co-authored-by: Wojt Janowski <wojt@clinically.com.au>
@wojt-janowski

Copy link
Copy Markdown
Contributor Author

Checked on an Android emulator (Pixel 9 Pro, Android 17) in a NativePHP app on nativephp/mobile 4.7.0, using a modal drawer. The drawer's root column is w-full h-full justify-between bg-emerald-100, with a header of 4 items (short) or 30 items (tall) and a pink footer. Main is on the left, this branch on the right.

On main, the short drawer's root hugs its content and the footer sits right under item 4. With this change the root fills the drawer and the footer is pinned to the bottom, where the tall drawer's footer ends up when scrolled to the end. The tall drawer still scrolls as before.

Light

Light mode, main and this branch

Dark

Dark mode, main and this branch

iOS was checked separately, in a package that hosts the real drawer host on the iOS 27 simulator: an h-full child went from 20 pt to the panel's full height.

@wojt-janowski
wojt-janowski marked this pull request as ready for review November 12, 2026 22:13
@simonhamp
simonhamp merged commit 7bbe9a1 into NativePHP:main Nov 14, 2026
4 checks passed
@simonhamp

Copy link
Copy Markdown
Member

good stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: Drawer content cannot fill viewport height or use justify-between / h-full to pin footer in NativeLayoutDrawerHost

2 participants