Skip to content

feat: add single-date selection to Date Range Picker - #274

Open
l4u532 wants to merge 2 commits into
starc007:mainfrom
l4u532:t3/beui-single-date-picker
Open

l4u532 wants to merge 2 commits into
starc007:mainfrom
l4u532:t3/beui-single-date-picker

Conversation

@l4u532

@l4u532 l4u532 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

tl;dr

  • A form that needs one date currently starts a range when the user chooses a day.
  • With mode="single", one activation selects the day and updates the trigger, summary, and announcement.
  • Range selection stays the default. The existing install slug and DateRange shape still work.

Selection contract

Both DateRangePicker and DateRangePickerDropdown accept mode="single". Controlled values, default values, and presets read from. Selection reports that day as both from and to. Clear reports null.

<DateRangePickerDropdown
  mode="single"
  defaultValue={{ from: "2026-11-04" }}
  max="2026-11-19"
  closeOnSelect
/>

The first activation completes the selection. An open dropdown closes on selection when closeOnSelect is set. The single-date status region stays mounted in the picker root, outside the panel. Its text remains available after close. After close, focus is on the trigger, which displays the new date.

The single-date footer keeps Clear and omits the built-in selection text. Custom compositions can pass children to DateRangePickerSelection or supply their own footer. Date bounds and disabled dates apply to day buttons and presets. Presets with the same start date represent the same selection in single mode. The controlled selection retains its object identity when only the visible month changes. Omitting mode or forwarding undefined keeps the two-step range flow. Switching modes clears the previous selection instructions. Existing range-only translation dictionaries still type-check, and single-date labels have English defaults.

Verification

Base c0a936f59eb767e263c0e81b93dd323511dc9b6b. Verified revision 147601b0418b11474f19eeee926f4b4708813f0b. The change includes the preview, component documentation, changelog, and accessibility cases. The date audit confirmed that only Date Range Picker needed an updated date. Its registry description now includes single-date selection.

  • bun run check passed, including 122 registry entries and message validation. Biome reported 15 warnings and two infos outside the changed files.
  • bun test passed all 222 accessibility tests. The new cases cover one selected grid cell and a status region that survives dropdown close.
  • Chrome 157, November 19, 2026. The local beUI fixture used the actual picker and preview on both revisions. Choosing November 5 with a November 4 default returned November 4–5 on the base. Single mode returned November 5 in both endpoints and showed one date on the trigger. The status text persisted after close. The default range case still returned November 4–5 and returned focus to the trigger. Keyboard navigation skipped disabled November 6. The controlled case covered value and open precedence, preset selection, Clear, Escape, a forwarded ref, and caller styling. Emulated touch passed at 390 px. The 320 px panel stayed within the viewport. Frame samples showed the departing panel had pointer events disabled. The day button held its static transform over 29 frames with reduced motion. The controlled value effect ran once on mount and stayed at one after paging to December.
  • Chrome confirmed that switching modes clears the previous status in both directions. It also confirmed the single-date footer shows Clear without a count and the live region stays inside the existing wrapper. A TypeScript check accepted the complete range dictionary from the base as DateRangePickerMessages.
  • Playwright WebKit 26.6, November 19, 2026. Keyboard open, arrow navigation, Enter, and focus return passed in the same local fixture. The settled trigger displayed November 5 and the status region retained the selection text.
  • Visible Safari 26.6.2 passed pointer selection, keyboard range navigation, Escape, and focus return. The single-date status showed “Thursday, November 5, 2026 selected.” It remained available during and after exit. Frame samples showed the exiting panel was inert with pointer events disabled. An iPad Pro 11-inch simulator on iOS 26.5 also passed touch selection and close. After tapping November 5, the accessibility tree showed the updated trigger and selection status. Physical iOS hardware and VoiceOver speech with closeOnSelect remain unverified.

Before and after

Choose November 5 from the November 4 default. The base shows both dates on the trigger. Single mode shows November 5 and keeps only Clear in the footer. Captured in Chrome on November 19, 2026, at base c0a936f and head 147601b.

Before-and-after date picker comparison

Compact calendar opening

Below 640 px, the whole calendar fades in together. Chrome and headless WebKit detected zero clipped footer frames at 320, 360, and 390 px after this change. iPhone Simulator Safari passed touch selection and close. The comparison shows 147601b and f0da86e at 390 px.

Compact calendar before and after

Test plan

  1. Open /components/motion/date-range-picker and choose an enabled day in the single-date example. The popover closes and the trigger shows one date.
  2. In the range example, choose a start and end. Confirm that the calendar highlights the range.
  3. Open the example above with Enter. Navigate to a new day and press Enter. Confirm focus returns to the trigger with the updated date.
  4. Repeat step 3 in visible Safari with VoiceOver and listen for the selected date on close.
  5. Run bun run check and bun test.

@l4u532

l4u532 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

tl;dr

  • Updated in f0da86e. Below 640 px, the calendar fades in as a complete surface so the opening clip cannot cut off the footer. Wider viewports retain the morph.
  • Chrome and headless WebKit went from 8–9 visible frames with Clear outside the hit-testable area to zero at 320, 360, and 390 px. At 768 px the morph still ran.
  • iPhone Simulator Safari passed touch selection and close. bun run check and all 222 accessibility tests passed.

The Chrome frames below show the opening at 390 px before (147601b) and after (f0da86e). The test sampled Clear’s center with elementFromPoint on each visible frame.

Before and after the calendar opening at 390 px

This branch has not been deployed

No deployments
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