Skip to content

fix(date-picker): match keyboard range selection to pointer behavior#3205

Open
olaf-k wants to merge 2 commits into
chakra-ui:mainfrom
olaf-k:fix/date-picker-range-keyboard
Open

fix(date-picker): match keyboard range selection to pointer behavior#3205
olaf-k wants to merge 2 commits into
chakra-ui:mainfrom
olaf-k:fix/date-picker-range-keyboard

Conversation

@olaf-k

@olaf-k olaf-k commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

📝 Description

This PR fixes the datepicker's keyboard range selection to match the pointer behavior. It also includes code to resume an incomplete range when reopening the calendar.

⛳️ Current behavior (updates)

When the datepicker is set with selectionMode: "range":

  1. If a range already exists, using the keyboard to reopen the calendar, navigate and select a new date incorrectly updates the current range and keeps the calendar open, instead of creating a new range (mouse behavior).
  2. When the previous point is fixed, selecting a date for a new range does not move focus to the next day, which is the behavior when creating a new range from an empty selection.
  3. The "range band" is not highlighted when creating ranges using non-arrow keys (e.g., Home/End or PgUp/PgDown), contrary to mouse behavior.
  4. Additionally, committing only a start date (keyboard or mouse) by selecting a day then clicking outside to close the calendar, does not allow users to complete the range when reopening it, as selecting another day starts a new range.

(All these scenarios can be reproduced locally or on the Chakra example page.)

🚀 New behavior

  1. resetSelection is used in keyboard navigation as it is with mouse navigation.
  2. focusNextDay is used when we're in this scenario.
  3. setHoveredValueIfKeyboard takes navigation using non-arrow keys into account.
  4. resumeRangeSelection added to cater to this particular scenario.

💣 Is this a breaking change (Yes/No):

No.

📝 Additional Information

The fourth point is a UX judgment call. As such, it has been isolated in a separate commit should you want to drop it and keep the current behavior.

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zag-nextjs Ready Ready Preview Jul 8, 2026 9:18am
zag-solid Ready Ready Preview Jul 8, 2026 9:18am
zag-svelte Ready Ready Preview Jul 8, 2026 9:18am
zag-vue Ready Ready Preview Jul 8, 2026 9:18am
zag-website Ready Ready Preview Jul 8, 2026 9:18am

Request Review

@changeset-bot

changeset-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d0baf58

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 86 packages
Name Type
@zag-js/date-picker Patch
@zag-js/anatomy-icons Patch
@zag-js/anatomy Patch
@zag-js/core Patch
@zag-js/docs Patch
@zag-js/preact Patch
@zag-js/react Patch
@zag-js/solid Patch
@zag-js/svelte Patch
@zag-js/vanilla Patch
@zag-js/vue Patch
@zag-js/accordion Patch
@zag-js/angle-slider Patch
@zag-js/async-list Patch
@zag-js/avatar Patch
@zag-js/carousel Patch
@zag-js/cascade-select Patch
@zag-js/checkbox Patch
@zag-js/clipboard Patch
@zag-js/collapsible Patch
@zag-js/color-picker Patch
@zag-js/combobox Patch
@zag-js/date-input Patch
@zag-js/dialog Patch
@zag-js/drawer Patch
@zag-js/editable Patch
@zag-js/file-upload Patch
@zag-js/floating-panel Patch
@zag-js/hover-card Patch
@zag-js/image-cropper Patch
@zag-js/listbox Patch
@zag-js/marquee Patch
@zag-js/menu Patch
@zag-js/navigation-menu Patch
@zag-js/number-input Patch
@zag-js/pagination Patch
@zag-js/password-input Patch
@zag-js/pin-input Patch
@zag-js/popover Patch
@zag-js/presence Patch
@zag-js/progress Patch
@zag-js/qr-code Patch
@zag-js/radio-group Patch
@zag-js/rating-group Patch
@zag-js/scroll-area Patch
@zag-js/select Patch
@zag-js/signature-pad Patch
@zag-js/slider Patch
@zag-js/splitter Patch
@zag-js/steps Patch
@zag-js/switch Patch
@zag-js/tabs Patch
@zag-js/tags-input Patch
@zag-js/timer Patch
@zag-js/toast Patch
@zag-js/toc Patch
@zag-js/toggle-group Patch
@zag-js/toggle Patch
@zag-js/tooltip Patch
@zag-js/tour Patch
@zag-js/tree-view Patch
@zag-js/store Patch
@zag-js/types Patch
@zag-js/aria-hidden Patch
@zag-js/auto-resize Patch
@zag-js/collection Patch
@zag-js/color-utils Patch
@zag-js/utils Patch
@zag-js/date-utils Patch
@zag-js/dismissable Patch
@zag-js/dom-query Patch
@zag-js/file-utils Patch
@zag-js/focus-trap Patch
@zag-js/focus-visible Patch
@zag-js/highlight-word Patch
@zag-js/hotkeys Patch
@zag-js/i18n-utils Patch
@zag-js/interact-outside Patch
@zag-js/json-tree-utils Patch
@zag-js/live-region Patch
@zag-js/popper Patch
@zag-js/rect-utils Patch
@zag-js/remove-scroll Patch
@zag-js/scroll-snap Patch
@zag-js/stringify-state Patch
svelte-kit-starter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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