Skip to content

feat(bottom-sheet): let the host name the header buttons of a stacked sheet - #87

Merged
romchornyi merged 2 commits into
dashpay:masterfrom
romchornyi-pitcrew:fix/sheet-header-ids
Dec 3, 2026
Merged

romchornyi merged 2 commits into
dashpay:masterfrom
romchornyi-pitcrew:fix/sheet-header-ids

Conversation

@romchornyi-pitcrew

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Closes #86.

BottomSheet draws its header buttons with NavigationBarElement.back.button and .close.button, so when one sheet is presented over another, both close buttons answer to navigationbar-close (and both back buttons to navigationbar-back). #85 added button(accessibilityIdentifier:action:), but the sheet's header had no way to receive one.

What was done?

  • View.bottomSheetHeaderIdentifiers(back:close:) puts the host's identifiers in the environment; the header passes them to button(accessibilityIdentifier:action:). nil keeps a button's fixed identifier.
  • An environment value, not an init parameter: it reaches a sheet built by BottomSheet.selfSizing(...), which returns some View, and leaves every existing signature as it is. A sheet presented from inside a named one inherits the names, so the docs say to give it its own.
  • docs/navigation-and-containers.md: the identifiers of the header buttons and the modifier, with an example.

How Has This Been Tested?

  • A throwaway app with an XCUITest target presents a BottomSheet and, from it, a BottomSheet.selfSizing with .bottomSheetHeaderIdentifiers(back: "inner-back", close: "inner-close"). With both open, navigationbar-close, navigationbar-back, inner-close and inner-back each match one button. Unit tests cannot read SwiftUI's accessibility tree, so no committed test reads the rendered header.
  • Whole suite, iPhone 17 simulator, iOS 26.5; conventions.sh.

Before / After

  • No visual change (refactor, tests, docs). Say why in "What was done?".

Only accessibility identifiers change; nothing is drawn differently.

Breaking Changes

None: a new modifier; without it the buttons keep their identifiers.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

🤖 Generated with Claude Code

… sheet

Two BottomSheets stacked both answered to navigationbar-close and navigationbar-back. View.bottomSheetHeaderIdentifiers(back:close:) puts the host's identifiers in the environment, and the header passes them to NavigationBarElement.button(accessibilityIdentifier:action:); nil keeps the fixed ones. It reaches BottomSheet.selfSizing too. Closes dashpay#86.

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

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@romchornyi romchornyi 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.

✅ No blockers, no major · 4 non-blocking recommendations — reviewed at 7b408626f4

Level Verdict
1 · Idea ✅ valid #86: two stacked sheets both answer to navigationbar-close / navigationbar-back.
2 · Architecture ✅ right layer An environment value reaches selfSizing and leaves every signature as it is.
3 · Completeness ✅ complete Back and close both covered; docs updated.
4 · Code ✅ clean CI green.
4 non-blocking recommendations
  1. Naming one button resets the other's outer name — BottomSheet.swift#L193 — the modifier writes both values, and the nil default clears a name set further up: .bottomSheetHeaderIdentifiers(close: "x") under a scope that named the back button gives it navigationbar-back again. Writing only the values passed would keep it.
  2. The names reach every nested sheet — navigation-and-containers.md#L174 — naming the outer sheet gives an inner one the same names, so the double match comes back under the custom identifier. The docs say so; scoping the value to the nearest sheet (clearing it for the sheet's own content) would make it impossible.
  3. The docs could name the UIKit boundary — same line — the names pass through SwiftUI .sheet / .fullScreenCover, not into a BottomSheet a UIHostingController presents, which the host app also does.
  4. No committed test — BottomSheet.swift#L147 — swapping the back and close values would stay green. A dump-based check like #85's overload test would pin the header wiring.
Review details

Levels 1–3 inline, level 4 /code-review high.

🤖 Reviewed with Claude Code

Review on dashpay#87:
- bottomSheetHeaderIdentifiers writes only the names passed, so naming the
  close button keeps a back name set further up.
- A BottomSheet clears the names for its content, so a sheet presented from
  it keeps its own fixed identifiers instead of inheriting the outer names.
- The docs say the names do not cross into a sheet a UIKit controller
  presents.
- BottomSheet.headerIdentifiers(back:close:) maps the names to the two
  buttons, with a test.

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

Copy link
Copy Markdown
Contributor Author

Review addressed in 9803494:

  1. The modifier writes only the names passed (transformEnvironment): naming the close button keeps a back name set further up.
  2. A BottomSheet clears the names for its content, so a sheet presented from it keeps its own fixed identifiers. The docs no longer ask the host to rename it.
  3. The docs say the names pass through .sheet / .fullScreenCover, not into a sheet a UIKit controller presents, and to apply the modifier inside the hosted view there.
  4. BottomSheet.headerIdentifiers(back:close:) maps the names to the buttons and the header uses it; BottomSheetHeaderIdentifierTests fails if they are swapped.

Checked in a throwaway XCUITest app: an outer sheet with close: "outer-close" and an inner selfSizing sheet with back: "inner-back" give outer-close, navigationbar-back (outer), inner-back and navigationbar-close (inner) one match each; the inner sheet does not inherit outer-close.

@romchornyi romchornyi 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.

✅ No blockers, no major · all 4 recommendations closed — re-reviewed at 98034943a6

Level Verdict
1 · Idea ✅ valid Unchanged.
2 · Architecture ✅ right layer Unchanged.
3 · Completeness ✅ complete Unchanged.
4 · Code ✅ clean The diff since 7b408626f4 scopes the names to their sheet and adds a test; CI green.

Closed since the last review

  • The modifier writes only the names passed (transformEnvironment), so naming one button keeps the other's outer name.
  • A BottomSheet clears the names for its content, so a sheet presented from it keeps its own.
  • The docs name the UIKit boundary.
  • BottomSheetHeaderIdentifierTests pins which name goes to which button.

🤖 Reviewed with Claude Code

@romchornyi
romchornyi merged commit 1267077 into dashpay:master Dec 3, 2026
9 checks passed
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.

BottomSheet: tell the header buttons of two stacked sheets apart in UI tests

2 participants