Skip to content

Fix period arrow keys hijacking custom-range calendar#6490

Open
sanne-san wants to merge 3 commits into
masterfrom
sanne-datepicker-shortcuts
Open

Fix period arrow keys hijacking custom-range calendar#6490
sanne-san wants to merge 3 commits into
masterfrom
sanne-datepicker-shortcuts

Conversation

@sanne-san

@sanne-san sanne-san commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Changes

  • On periods with < > controls (Today, Month to Date, Last Month, Year to Date, specific day/month/year), the document-level ArrowLeft/ArrowRight listener kept firing while the calendar popover was open, silently shifting the period and closing the calendar.
  • Suppress that listener whenever a flatpickr calendar is mounted, via a new isDateRangeCalendarOpen predicate on Keybind.shouldIgnoreWhen.
  • Added a regression test covering both directions: arrows still shift the period when the calendar is closed, and no longer do so while it's open.

Tests

  • Automated tests have been added

Changelog

  • Entry has been added to changelog

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

- On periods with `< >` controls (Today, Month to Date, Last Month, Year to Date, specific day/month/year), the document-level ArrowLeft/ArrowRight listener kept firing while the calendar popover was open, silently shifting the period and closing the calendar.
- Suppress that listener whenever a flatpickr calendar is mounted, via a new `isDateRangeCalendarOpen` predicate on `Keybind.shouldIgnoreWhen`.
- Added a regression test covering both directions: arrows still shift the period when the calendar is closed, and no longer do so while it's open.
@sanne-san sanne-san added bug Something isn't working preview labels Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Preview environment👷🏼‍♀️🏗️
PR-6490

1 similar comment
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Preview environment👷🏼‍♀️🏗️
PR-6490

@sanne-san sanne-san requested a review from a team July 8, 2026 08:59

@RobertJoonas RobertJoonas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on staging and it does what intended, so approving 👍

I feel like there's another side to actually making it work though -- the calendar doesn't automatically gain focus. For example, if I hit the down arrow right after opening the calendar, it'll start scrolling down the page (browser default). So even though left/right arrow keys are not affecting the rest of the page (which is correct of course), the keypresses are not registered by the calendar itself either. This is the behaviour I've experienced on Chrome and Safari at least.

Comment thread assets/js/dashboard/nav-menu/query-periods/dashboard-dates.test.tsx Outdated
Comment thread assets/js/dashboard/nav-menu/query-periods/move-period-arrows.tsx Outdated
@sanne-san

Copy link
Copy Markdown
Contributor Author

Tested on staging and it does what intended, so approving 👍

I feel like there's another side to actually making it work though -- the calendar doesn't automatically gain focus. For example, if I hit the down arrow right after opening the calendar, it'll start scrolling down the page (browser default). So even though left/right arrow keys are not affecting the rest of the page (which is correct of course), the keypresses are not registered by the calendar itself either. This is the behaviour I've experienced on Chrome and Safari at least.

@RobertJoonas agree – I actually tried to fix this too but didn't succeed. Since the bug report was about this specifically, I thought it was worth shipping this as-is so that someone else can look into that separately. I will implement your feedback so this can go out and add a card for that as a separate issue!

@sanne-san sanne-san requested a review from RobertJoonas July 8, 2026 11:57
@sanne-san sanne-san force-pushed the sanne-datepicker-shortcuts branch from f92e361 to 2f3f364 Compare July 8, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants