Skip to content

feat: modernize drawer - #5052

Merged
Doberjohn merged 21 commits into
callstack:mainfrom
ziarno:feat/modernize-drawer
Nov 24, 2026
Merged

Doberjohn merged 21 commits into
callstack:mainfrom
ziarno:feat/modernize-drawer

Conversation

@ziarno

@ziarno ziarno commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Aligns Drawer with the MD3 navigation drawer spec. API unchanged.

  • 28dp content inset on both sides (was 36dp trailing)
  • Active label emphasized (700)
  • Focused, hovered and pressed inactive items use onSurface
  • Section divider follows the theme (outlineVariant)
  • Disabled destinations dim their content
  • Active item: aria-selected on iOS/Android, aria-current="page" on web
  • Shape and motion tokens, in new Drawer/tokens.ts

Related issue

Closes #4981

Screenshots / Videos

Before After

Test plan

Example app → Drawer, light and dark: active, disabled and collapsed items; keyboard focus on web; TalkBack announces the active item.

Filip Jarno and others added 13 commits August 11, 2026 10:56
Bring `Drawer.Item` and `Drawer.Section` in line with the current
`md.comp.navigation-drawer` token set and extract component-specific
tokens. The public API is unchanged.

- Extract `Drawer/tokens.ts` with `DrawerItemTokens`,
  `DrawerSectionTokens` and `DrawerCollapsedItemTokens`. The last one
  cites `md.comp.navigation-rail`, which is what actually specifies
  `Drawer.CollapsedItem`.
- Correct the item's trailing padding from 36dp to the spec'd 28dp, so
  both container insets match.
- Emphasize the active destination's label, per
  `md.comp.navigation-drawer.active.label-text.weight`.
- Add the MD3 focus indicator. It uses the *inner* offset, so the ring
  is drawn inside the active indicator: destinations sit flush, and an
  outer ring would overlap its neighbours.
- Resolve the active indicator radius from the `full` shape token
  instead of hardcoding `extraLarge`.
- Drop the hardcoded `Palette.neutralVariant50` section divider colour,
  which ignored the theme and was wrong in dark mode. Drawer divider
  tokens are deprecated in MD3, so the standalone divider spec
  (`outlineVariant`, 1dp) applies.
- Use `marginStart`/`marginEnd` for directional spacing. React Native
  auto-swaps left/right in RTL, but react-native-web does not.
- Collapse the leftover v2/v3 style splits and the duplicated typescale
  spread in `Drawer.Item` and `Drawer.Section`.

Supporting theme changes, both additive:

- `TypescaleKey` gains the 15 `*Emphasized` keys. The values already
  existed in `md.sys.typescale` but no type exposed them.
- `md.sys.state.focusIndicator` gains `innerOffset`.

`Drawer.CollapsedItem` renders identically; only its magic numbers moved
into tokens.

Refs: callstack#4981

Co-Authored-By: Claude Opus 5 <[email protected]>
- Add a `Drawer` screen to the example app, inside a 360dp surface
  standing in for the drawer container so the active indicator sits at
  its spec'd proportions. Covers active/inactive destinations, no icon,
  a truncated label, disabled, both trailing-slot shapes, sections
  separated by a divider, and collapsed destinations.
- Give the example app's own drawer the MD3 container: 360dp wide,
  `surfaceContainerLow`, and rounded corners on the ending edge only.
  Collapse its leftover v3 style split while there.
- Document the section divider and focus indicator colour roles.
- Add a `Drawer` section to the 6.x migration guide. The API is
  unchanged, but four visual changes are worth calling out for anyone
  pixel-matching against 5.x.
- Recapture `drawer-item` and `drawer-section` screenshots against the
  new rendering. Both are now device-agnostic crops; the old
  `drawer-section` shot was an Android emulator window, which cannot be
  reproduced from an iOS Simulator. `drawer-collapsed` is unchanged,
  since `Drawer.CollapsedItem` renders identically.

Co-Authored-By: Claude Opus 5 <[email protected]>
Add `.agents/CONTEXT.md`, a glossary of the Material Design terms this
project keeps getting wrong in review — the ref/sys/comp token tiers,
state layer, focus indicator, active indicator, standard vs modal
drawer.

Add `.agents/adr/` with the three Drawer decisions a future reader would
otherwise have to reverse-engineer: why Paper ships drawer destinations
but no container, why `TypescaleKey` grew the emphasized keys, and why
`Drawer.Item` alone among modernized components keeps `TouchableRipple`
rather than rendering its own state layer.

Co-Authored-By: Claude Opus 5 <[email protected]>
The hand-maintained `docs/src/data/themeColors.ts` still referenced v5 color
roles and pre-v6 component behaviour, so the generated `ThemeColorsTable`
documented roles that no longer exist on `ThemeColors`.

Removed roles that are not on the type:
- `surfaceDisabled` / `onSurfaceDisabled` - v6 draws disabled states from
  `onSurface` at a reduced opacity
- `backdrop` (Modal) - now `scrim` at 32%
- `elevarion.level3` - typo, and the surface FAB variant no longer exists

Re-checked every remaining entry against what the component renders:
- Appbar / Appbar.Header elevated: `surfaceContainer`, not `elevation.level2`
- Button elevated: `surfaceContainerLow`; outlined border: `outlineVariant`
- Dialog and Searchbar: `surfaceContainerHigh`
- IconButton outlined border: `outlineVariant`
- SegmentedButtons checked border: `outline`; disabled border: `outlineVariant`
- FAB: replaced the old variant list with the MD3 `primary`/`secondary`/
  `tertiary`/`tonal*` variants, and swapped the removed `AnimatedFAB` entry
  for `FAB.Extended`
- Snackbar: document container and label colors alongside the icon color

Co-Authored-By: Claude Opus 5 <[email protected]>
`disabled` blocked touch but had no visual effect, so a disabled
destination was indistinguishable from an enabled one.

MD3's navigation drawer and rail token sets define no disabled state, so
fall back to the generic disabled-content opacity
(`md.sys.state.opacity.disabled`) via a shared `stateOpacity` token.
Applied at container level, as Checkbox and Menu.Item do, so the active
indicator, icon, label and trailing slot dim together.

Co-Authored-By: Claude Opus 5 <[email protected]>
Git worktrees created under .claude/worktrees/ were crawled by Jest from
the repo root, doubling the collected suites (110 instead of 55) and
producing spurious failures from mismatched snapshots and duplicate
module registration across checkouts. This also hit the lefthook
pre-commit hook, which runs `test` from the repo root.

Add <rootDir>/.claude/ to modulePathIgnorePatterns, which scopes both
test discovery and module resolution.

Co-Authored-By: Claude Opus 5 <[email protected]>
Revert changes that belong in their own PR, and finish wiring up the
token modules introduced earlier in this branch.

- Revert the theme colour table corrections for Appbar, Button, Dialog,
  FAB, IconButton, Menu, Modal, Searchbar, SegmentedButtons and
  Snackbar, along with the `.claude` jest ignore. The Drawer's own
  entries (`Drawer.Item` focus indicator, `Drawer.Section` divider)
  stay, since those document changes made here.
- Drive the collapsed item's press animation from `theme.motion` rather
  than a hardcoded 150ms. `short3` is that same duration; the easing now
  follows the MD3 standard curve instead of Animated's default.
- Resolve the collapsed item's active indicator radius through
  `resolveCornerRadius`, as `Drawer.Item` already does.
- Colour the `Drawer.Item` label from the `*LabelTextColor` tokens,
  which were declared but never read.
- Hide the focus indicator on disabled destinations.

Co-Authored-By: Claude Opus 5 <[email protected]>
The screenshots taken in b746c65 showed different views than the ones
they replaced, so they no longer read as a before/after of the same UI.
Recapture both against the views the originals used:

- `drawer-item`: a tight crop of a single active "Sent mail" destination,
  with the same relative margins as the 5.x crop.
- `drawer-section`: the example app's own drawer, open on the "Example
  items" section with Inbox active.

Both are Android emulator captures. They lack the macOS window chrome the
5.x shots had, since that needs an interactive window capture.

Co-Authored-By: Claude Opus 5 <[email protected]>
@ziarno ziarno changed the title Feat/modernize drawer feat: modernize drawer Aug 16, 2026

@MikitasK MikitasK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
just one small suggestion:

Comment thread src/components/Drawer/DrawerItem.tsx Resolved
JKobrynski

This comment was marked as resolved.

@satya164

Copy link
Copy Markdown
Contributor

Review by Claude

Web

Drawer.CollapsedItem shows the browser's default focus outline

Steps: open the Drawer example, press Tab until focus reaches the first item under "Collapsed destinations".

What happens: the browser draws its default square blue outline around the 80dp container. Drawer.Item now draws the MD3 focus ring in theme.colors.secondary, so the two parts of the same drawer look different on keyboard focus.

What should happen: a focus ring in theme.colors.secondary that follows the active indicator shape, with the default outline removed, as in Drawer.Item.

Web, Drawer.CollapsedItem with keyboard focus: default blue browser outline (via Claude, verify if it makes sense)

@satya164 satya164 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Claude

See the inline comments. (via Claude, verify if it makes sense)

Comment thread docs/6.x/docs/guides/migration.md Resolved
Comment thread docs/6.x/docs/guides/migration.md Resolved
Comment thread docs/6.x/docs/guides/migration.md Resolved
Comment thread docs/6.x/docs/guides/migration.md Resolved
Comment thread example/src/Examples/DrawerExample.tsx Resolved
@Doberjohn Doberjohn added this to the 6.0.0 milestone Oct 30, 2026
@Doberjohn Doberjohn modified the milestones: 6.0.0, 6.0.0-beta.0 Nov 12, 2026
Filip Jarno and others added 3 commits November 18, 2026 14:50
Conflict resolution:

- Drop the generated component docs (`DrawerItem.mdx`, `DrawerSection.mdx`,
  `componentDocs6x.json`), which main no longer keeps in the repo.
- `Drawer.CollapsedItem`: keep main's Reanimated indicator animation and
  focus ring, and drive the animation from the `short3`/`standard` motion
  tokens instead of the hardcoded 150ms ease.
- `Drawer.Item`: drop the hand-drawn focus ring and the `innerOffset` token
  it needed. `TouchableRipple` now draws the MD3 ring itself
  (`focusRing="inward"`), so keeping both would draw two.
- Migration guide: drop the note on the emphasized typescale keys, which
  main already added to `TypescaleKey`.
- Tests: query destinations with a press handler, since a handler-less
  `TouchableRipple` is no longer exposed as a button.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Expose destinations as tabs on Android and web, as BottomNavigation
  does, so `aria-selected` announces the active one. iOS keeps `button`,
  since it has no tab role outside a tab bar.
- Dim only the content of a disabled destination, like Menu.Item. The
  active indicator keeps its color, so a disabled active destination
  still reads as active.
- Remove the default `drawer-item-content` and `drawer-section-divider`
  test IDs.
- Drop the tests that asserted internal inset values; the snapshots cover
  them.
- Example: give the icon-only collapsed destination an accessible name.
- Migration guide: describe the trailing padding change accurately, drop
  the `style` workaround that moved the indicator instead of the content,
  and list the focus ring and disabled changes for `Drawer.CollapsedItem`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ziarno
ziarno requested a review from JKobrynski November 18, 2026 14:25
Stoneski93

This comment was marked as resolved.

Filip Jarno and others added 2 commits November 23, 2026 10:17
- Go back to `role="button"` on every platform. A `tab` needs a
  `tablist` parent and arrow-key navigation, which a drawer doesn't have.
  iOS and Android keep `aria-selected`, which they announce on a button.
  On web the active destination gets `aria-current="page"` instead, since
  `aria-selected` isn't valid on a button.
- Use `onSurface` for inactive hovered and pressed destinations, as the
  navigation drawer tokens specify, alongside the focused state.
- Example: make every enabled destination pressable, so each one can be
  focused and shows its states on web, and round the ending edge of the
  drawer content to match the MD3 container.
- Migration guide: note the `aria-current` change on web.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Stoneski93 Stoneski93 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked on web and Android (TalkBack). All points are addressed: destinations are valid buttons with aria-current="page" on web and selected on Android, inactive hover/pressed use onSurface, and the example is fixed. The only thing left is the focus state layer, which no component has yet, so it can be a follow-up.

@Doberjohn
Doberjohn dismissed JKobrynski’s stale review November 24, 2026 09:46

All points were answered on 2026-11-18: the default test IDs are gone, Drawer.CollapsedItem animates with Reanimated since #5015, the active destination has valid semantics, and disabled items dim their content instead of the indicator. Stoneski93 re-checked the head on web and Android.

Clarified the description of the Drawer API changes in Paper 6.x, including padding adjustments, label weight updates, and section divider color updates.
@Doberjohn
Doberjohn merged commit 8cf0688 into callstack:main Nov 24, 2026
10 checks passed
@ziarno
ziarno deleted the feat/modernize-drawer branch November 24, 2026 10:32
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.

feat: modernize Drawer to latest Material Design Specs

6 participants