Skip to content

Replace react-dates on mobile DateInput with native picker#4343

Merged
lbwexler merged 8 commits into
developfrom
react-dates
Jun 5, 2026
Merged

Replace react-dates on mobile DateInput with native picker#4343
lbwexler merged 8 commits into
developfrom
react-dates

Conversation

@amcclain

@amcclain amcclain commented Apr 18, 2026

Copy link
Copy Markdown
Member

Summary

  • Replaces the mobile DateInput's internal picker with the browser's native <input type="date">, removing the abandoned react-dates dependency (last release Jan 2020, React peer caps at v16, unfixed SASS issue we had been monkey-patching with a copied CSS file).
  • Public DateInput component, HoistInputModel wiring, and the clear-button pattern are unchanged. Breaking removals on DateInputProps: formatString, initialMonth, placeholder, singleDatePickerProps — all documented in the changelog under 💥 Breaking Changes.
  • Eliminates 8 yarn install peer-dep warnings and deletes ~900 lines of copied CSS plus the kit/react-dates/ sub-package.

Toolbox mobile uses only baseline DateInput props (minDate, maxDate, textAlign, valueType); no Toolbox changes required.

Test plan

⚠️ Must be verified on real iOS and Android devices. This swaps in the OS-native date control, which Chrome's device-toolbar emulation does not faithfully render — emulation uses the desktop rendering engine (you get the desktop popover, and in some cases the popover is suppressed entirely). The emulator is therefore not a valid surface for this change. See the addendum below for connecting a physical device from a Mac.

  • Mobile DateInput in Toolbox FormPage opens the OS-native picker (iOS wheel, Android Material dialog) — tested on a real device, not the emulator.
  • minDate/maxDate constraints enforced via native UI and on programmatic commit; out-of-range values reset to null.
  • enableClear button clears value and does not reopen the OS picker.
  • valueType: 'localDate' round-trips correctly; valueType: 'date' (default) unchanged.
  • yarn install no longer emits react-dates-related peer warnings.

Hoist P/R Checklist

  • Caught up with develop branch as of last change.
  • Added CHANGELOG entry (under 💥 Breaking Changes for 86.0.0-SNAPSHOT).
  • Reviewed for breaking changes; please apply breaking-change label.
  • Updated doc comments / prop-types (DateInputProps TSDoc refreshed, kit/README.md + docs/test-automation.md updated).
  • Reviewed and tested on Mobile.
  • Created Toolbox branch / P/R, or determined not required — not required; verified Toolbox uses only unchanged props.

📱 Addendum — running the Toolbox dev build on a physical device from a Mac

In both cases you need two things: (1) the device must reach the Mac's dev server, and (2) a remote inspector to debug. The approach differs by platform because Android and iOS expose localhost differently.

Android (Chrome) — USB port forwarding (keeps localhost)

Reach the dev server:

  1. On the phone, enable Developer options → USB debugging.
  2. Connect via USB and accept the debugging prompt.
  3. In desktop Chrome, open chrome://inspect/#devices and ensure Discover USB devices is checked.
  4. Click Port forwarding…, add a rule mapping device port 3000localhost:3000, and enable it.
  5. On the phone, open Chrome to http://localhost:3000/mobile. Traffic tunnels over USB to the Mac, so the standard yarn startWithHoist (bound to localhost) works unchanged.

Inspect: back in chrome://inspect, the page appears under the device — click inspect for full remote DevTools.

iOS (Safari) — LAN access (no Chrome-style port forwarding)

Reach the dev server over Wi-Fi, since iOS has no USB port forwarding:

  1. Put the iPhone and Mac on the same Wi-Fi network.
  2. Start the dev server bound to the Mac's LAN IP: yarn startWithHoistAndIp (Toolbox script — runs webpack with --env devHost=$(ipconfig getifaddr en0)).
  3. On the iPhone, open Safari to http://<mac-LAN-ip>:3000/mobile (the IP the start script prints).

Inspect via Safari Web Inspector over USB:

  1. iPhone: Settings → Safari → Advanced → Web Inspector = ON.
  2. Mac Safari: Settings → Advanced → Show features for web developers (enables the Develop menu).
  3. Connect via USB and trust the Mac.
  4. Mac Safari → Develop → [your iPhone] → [the page] opens Web Inspector.

Tip: after restarting the dev server, fully reload on the device (close and reopen the tab) — a stale HMR client can otherwise throw webpackHotUpdate errors trying to patch a bundle that no longer matches.

Generated with Claude Opus 4.7 (1M context)

amcclain and others added 3 commits April 18, 2026 08:50
…="date">

The react-dates library was last released in January 2020 and is effectively abandoned. Its React peer dependency caps at v16, generating ~8 yarn install warnings against our React 18 runtime, and the library won't fix known SASS/darken() issues (hence our copied datepicker.css monkey-patch).

Usage was narrow - only the mobile DateInput, and only SingleDatePicker. Swapped the internal picker for the browser's native <input type="date">, which delivers the OS-native date UI (wheel on iOS, Material dialog on Android, popover on desktop) with no library surface. Kept the HoistInputModel-backed DateInput component, its public API (value, min/max, valueType, enableClear, icons, textAlign), and the clear-button pattern from TextInput.

Breaking removals (no downstream usage found in Toolbox): formatString, initialMonth, placeholder, singleDatePickerProps. Also deleted kit/react-dates/ and the copied datepicker.css. Apps with custom SCSS targeting the old react-dates class names should clean those up - noted in the changelog.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lbwexler lbwexler self-assigned this Jun 5, 2026
The appearance-reset, sizing, and pseudo-element rules were scoped to
.xh-date-input__input, which onsen applies to the <ons-input> wrapper
rather than the inner native <input>. Retarget them at .text-input /
.text-input__label, following the sibling TextInput/NumberInput pattern,
so native date chrome is actually stripped and sizing is consistent.
@lbwexler lbwexler marked this pull request as ready for review June 5, 2026 18:28
@lbwexler lbwexler requested a review from TomTirapani June 5, 2026 18:28
amcclain and others added 4 commits June 5, 2026 12:35
When an out-of-bounds date is selected and reset to null, `setInternalValue` short-circuits if the prior value was also null (the common empty-field case), so no re-render fires and the rejected value stays visible in the native input while the model reads null.

Imperatively clear the element value on reset to keep the control in sync with the committed model value.
iOS renders the formatted value in `::-webkit-date-and-time-value`, which carries a default margin and aligns to the top of the fixed-height control. Reset that margin and set `line-height` to center the value, leaving the horizontal `textAlign` behavior intact.
+ Rebuild yarn.lock
@lbwexler lbwexler merged commit 2d043fe into develop Jun 5, 2026
3 checks passed
@lbwexler lbwexler deleted the react-dates branch June 5, 2026 20:25
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.

2 participants