Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DateRangeInput3) Add keyboard accessibility #7080

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

jscheiny
Copy link
Contributor

@jscheiny jscheiny commented Nov 19, 2024

Changes proposed in this pull request:

This PR adds improved keyboard accessibility to the DateRangeInput3 component. In particular we align with other date range picker so that when one of the input fields is focused, the user can then use their arrow keys to navigate the calendar and make selections. This properly respects min and max dates and allow single selection only and properly navigates the calendar view based on user selections.

Screenshot

date-range-input.mp4

@changelog-app
Copy link

changelog-app bot commented Nov 19, 2024

Generate changelog in packages/datetime2/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

feat(DateRangeInput3) Add keyboard accessibility

Check the box to generate changelog(s)

  • Generate changelog entry

@jscheiny jscheiny marked this pull request as ready for review November 19, 2024 20:19
@svc-palantir-github
Copy link

feat(DateRangeInput3) Add keyboard accessibility

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link

Fix overlapping dates

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@svc-palantir-github
Copy link

Fix same date overlap

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

const isForwardArrowKey = arrowKey === "ArrowRight" || arrowKey === "ArrowDown";
// If the arrow key direction is in the same direction as the boundary, then moving that way will not create an
// overlapping date range
if (isForwardArrowKey === (boundary === Boundary.END)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The equivalence of a boolean to a boolean here reads a bit weird. Can we change this to something like:

const isForwardArrowKey = arrowKey === "ArrowRight" || arrowKey === "ArrowDown";
const isEndBoundary = boundary === Boundary.END;
// If the arrow key direction is in the same direction as the boundary, then moving that way will not create an
// overlapping date range
if (isForwardArrowKey && isEndBoundary) {
    return shiftDateByArrowKey(otherBoundary, arrowKey);
}

Copy link
Contributor Author

@jscheiny jscheiny Nov 21, 2024

Choose a reason for hiding this comment

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

We still need equality here for this to work properly, isForwardArrowKey && isEndBoundary is not equivalent to isForwardArrowKey === isEndBoundary. I thought about doing something like:

const arrowKeyDirection = arrowKey === "ArrowRight" || arrowKey === "ArrowDown" ? "forward" : "backward";
const boundaryDirection = boundary === Boundary.END ? "forward" : "backward";
if (arrowKeyDirection === boundaryDirection) {

But this is just a lot of extra stuff for the same thing and minimal readability improvement. I'll pull isEndBoundary out I like that, but I'm not sure how to make it much more readable beyond that.

@jscheiny jscheiny merged commit dc7c104 into develop Nov 22, 2024
12 of 14 checks passed
@jscheiny jscheiny deleted the js/date-range-input-keyboard-access branch November 22, 2024 14:41
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.

3 participants