feature: opt-in disabled prop on top-bar actions - #378
Open
SRWieZ wants to merge 1 commit into
Open
Conversation
Top-bar actions had no way to represent an unavailable state (undo with nothing to undo, save with no changes) — apps had to hide the action, which makes the bar jump. `disabled` greys the button and swallows the tap: iOS adds .disabled() plus an explicit 0.4 opacity (the label's hard-set foregroundColor keeps SwiftUI's automatic dimming from showing), Android passes enabled=false to IconButton so M3's disabled content tone applies on its own. Menu triggers and menu sub-items honor it too. NavAction gains a fluent ->disabled(); attributes are reactive, so :disabled="! $this->canUndo" tracks screen state live. Unset keeps today's behavior everywhere.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's wrong
A top-bar action can't be greyed out. When an action is sometimes unavailable (undo with nothing to undo, save with no changes), the only option is to hide it — and the bar jumps as icons appear and disappear.
What this does
One opt-in prop:
disabled. The button greys out and ignores taps. Unset keeps exactly today's behavior.Chrome attributes are reactive, so
:disabled="! $this->canUndo"greys and un-greys live as screen state changes. TheNavActionbuilder gets the same:NavAction::make('undo')->icon('undo')->disabled(! $canUndo)..disabled()on the Button, plus an explicit 0.4 opacity — the action label hard-sets itsforegroundColor, which keeps SwiftUI's automatic dimming from showing.enabled = falseon theIconButton— Material 3 swaps in the disabled content tone on its own.Tests: serialization on the element (set / unset / boolean coercion / explicit false) and through the
NavActionbuilder.On device (same Blade as above)
Android emulator, API 36 — Undo greyed while there is nothing to undo, live again right after adding a note (the same screen, one tap apart):
iOS simulator, iPhone 17 — the disabled Undo next to the live Add: