Skip to content

feat(date-picker): clear a picked date from inside the field - #204

Open
fkrzski wants to merge 3 commits into
NativePHP:mainfrom
fkrzski:feat/clearable-date-picker
Open

fkrzski wants to merge 3 commits into
NativePHP:mainfrom
fkrzski:feat/clearable-date-picker

Conversation

@fkrzski

@fkrzski fkrzski commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

A compact native:date-picker gets a clearable attribute: while it holds a value, an X sits inside the field (beside the calendar icon on Android, beside the date button on iOS), and tapping it sends '' through @change / native:model — the empty value the wire already uses for "nothing chosen" — without opening the dialog; clear-label names the X for screen readers. On Android the transparent box laid over the field to catch its tap would have swallowed the X as well, so the field now opens the dialog from its own interaction source and its accessibility click, and never takes focus, which keeps its resting look. Checked on an Android 14 device and with a new Robolectric test in tests/android, since CI does not build Kotlin. I have no iOS device, so the Swift side follows the existing renderer and is covered only by a source-text test — could someone check it on iOS?

On Android the box laid over the field to catch its tap would swallow
the X too, so the field opens its dialog from its own interaction source.
@fkrzski
fkrzski force-pushed the feat/clearable-date-picker branch from 3285ff3 to 5a6e496 Compare November 12, 2026 17:28
wojt-janowski added a commit to wojt-janowski/mobile-ui that referenced this pull request Nov 12, 2026
Amp-Thread-ID: https://ampcode.com/threads/T-01a1d162-a328-74ca-9736-3ea00ba24361
Co-authored-by: Wojt Janowski <wojt@clinically.com.au>
@wojt-janowski

Copy link
Copy Markdown
Contributor

@fkrzski I checked the iOS side on the simulator (iPhone 17 Pro, iOS 26.5), in a NativePHP app on nativephp/mobile 4.7.0 with mobile-ui at 5a6e496. The test screen had five compact pickers: clearable with native:model and a value, clearable and empty, clearable with @change, not clearable, and clearable but disabled. It works as described:

  • The X shows only beside a picked date. The empty, not-clearable and disabled pickers have none.
  • Tapping the X clears without opening the calendar. The native:model property became '' and the field fell back to its placeholder, and @change received ''.
  • After clearing, tapping the placeholder picks today and the X comes back, the same as a picker that was never set.
  • Tapping the date itself still opens the calendar popover, and picking a day updates the property.
  • In dark mode the X uses the theme's muted colour and stays visible.

iOS simulator: on launch, after clearing, calendar open, dark mode

From left: on launch, after tapping the X on the first and third pickers, the calendar opened from the date, and dark mode. The lines under each picker are plain native:text, so they go dark-on-dark in dark mode; that's #89, not this PR.

I didn't check VoiceOver, so the clear-label announcement is untested.

@fkrzski

fkrzski commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for checking it on iOS, @wojt-janowski. That was the one part I couldn't run myself.

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.

3 participants