Skip to content

feature: opt-in disabled prop on top-bar actions - #378

Open
SRWieZ wants to merge 1 commit into
NativePHP:mainfrom
SRWieZ:feat/top-bar-action-disabled
Open

feature: opt-in disabled prop on top-bar actions#378
SRWieZ wants to merge 1 commit into
NativePHP:mainfrom
SRWieZ:feat/top-bar-action-disabled

Conversation

@SRWieZ

@SRWieZ SRWieZ commented Aug 25, 2026

Copy link
Copy Markdown
Member

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.

<native:top-bar title="Notes">
    <native:top-bar-action id="undo" icon="arrow.uturn.backward" :disabled="! $this->canUndo" @tap="undo" />
    <native:top-bar-action id="add" icon="plus" @tap="addItem" />
</native:top-bar>

Chrome attributes are reactive, so :disabled="! $this->canUndo" greys and un-greys live as screen state changes. The NavAction builder gets the same: NavAction::make('undo')->icon('undo')->disabled(! $canUndo).

  • iOS: .disabled() on the Button, plus an explicit 0.4 opacity — the action label hard-sets its foregroundColor, which keeps SwiftUI's automatic dimming from showing.
  • Android: enabled = false on the IconButton — Material 3 swaps in the disabled content tone on its own.
  • Menu triggers (actions with sub-items) and menu rows honor it too.

Tests: serialization on the element (set / unset / boolean coercion / explicit false) and through the NavAction builder.

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:

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