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

Respect showOutsideDays prop for single month date range #6862

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from

Conversation

evansjohnson
Copy link
Contributor

@evansjohnson evansjohnson commented Jun 24, 2024

Fixes #4373

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

When a DateRangePicker3 is limited to a single month, respect the showOutsideDays passed on dayPickerProps. Per https://github.com/palantir/blueprint/pull/586/files#r98813760 it was explicitly decided that showing outside days when multiple months are shown is not intended, and I agree that it still leads to some weird questions, but for a single month these issues do not exist.

Reviewers should focus on:

  • Is this the behavior we want?
  • Do the updated docs look good?
  • Only fixing on DateRangePicker3 since DateRangePicker is deprecated and frozen.

Alternate option

Simply document that showOutsideDays is never respected for DateRangePicker3

Screenshot

Screenshot 2024-06-24 at 4 06 48 PM
Screenshot 2024-06-24 at 4 06 43 PM


assert.equal(left.findOutsideDays().first().getDOMNode().computedStyleMap().get("pointer-events")?.toString(), "none");

// simulated clicks appear to not respect pointerEvents style or else would test with below
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no activity on it but I found enzymejs/enzyme#2340

open to suggestions for better ways to disable the interaction or better ways to test this


it("allows outside days to be shown for single month date range", () => {
const { left } = render({ initialMonth: new Date(2015, Months.DECEMBER, 2), singleMonthOnly: true, dayPickerProps: { showOutsideDays: true } });
assert.equal(left.findOutsideDays().first().getDOMNode().computedStyleMap().get("visibility")?.toString(), "visible");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

open to suggestion for better way to test visibility here

@@ -1332,6 +1332,33 @@ describe("<DateRangePicker3>", () => {
});
});

describe("outside days", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these tests are very closely tied to the implementation but figured it was good to get something in testing the behavior so this doesn't unintentionally regress

@palantir palantir deleted a comment from svc-palantir-github Jun 27, 2024
@palantir palantir deleted a comment from svc-palantir-github Jun 27, 2024

/* stylelint-disable max-line-length */
&.#{$ns}-datepicker.#{$ns}-daterangepicker-single-month.#{$ns}-daterangepicker-showing-outside-days .rdp-day_outside {
pointer-events: none; // weird interactions happen if allowing outside days to be clicked
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that without this, selecting a date in the earlier "outside days" switches to the previous month. This doesn't seem ideal since there will not be many days ahead of that initial date selected once we switch to the previous month, but the user can reselect the month after making the start date selection.

Also note that we only need to worry about click and not keyboard nav events here because we still want to allow keyboard nav with arrow keys to navigate between months. The difference is that keyboard nav is navigation, then selection, while mouse interaction is selection and navigation which felt a bit jarring.

Open to suggestions for a better solution here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would be curious for @alex-dales's opinion. Playing around with the UI, I actually found it surprising that I couldn't click on the grayed out dates. It might not be obvious to some users that they have to switch to the previous month intentionally to select these "outside day" dates?

@palantir palantir deleted a comment from svc-palantir-github Jun 27, 2024
@palantir palantir deleted a comment from svc-palantir-github Jun 27, 2024
@palantir palantir deleted a comment from svc-palantir-github Jun 27, 2024
@palantir palantir deleted a comment from svc-palantir-github Jun 27, 2024
@svc-palantir-github
Copy link

assert warn

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

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

@evansjohnson evansjohnson marked this pull request as ready for review June 27, 2024 20:32
Copy link
Contributor

@gluxon gluxon left a comment

Choose a reason for hiding this comment

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

Implementation and tests look good! (Or, the tests look as good as they can be. I don't know of a better way to check for visibility. 😂)

I lean towards allowing the outside days to be click-able, but will let you and @alex-dales make the final call on the right UX for that.

@@ -59,6 +59,14 @@
}
}


/* stylelint-disable max-line-length */
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: I usually like to use stylelint-disable-next-line whenever possible to avoid the need to re-enable the lint rule further down.

Suggested change
/* stylelint-disable max-line-length */
// stylelint-disable-next-line max-line-length

pointer-events: none; // weird interactions happen if allowing outside days to be clicked
visibility: visible; // showing outside days is allowed for single months
}
/* stylelint-enable max-line-length */
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: It should be possible to remove this after using // stylelint-disable-next-line above.

@@ -1332,6 +1332,55 @@ describe("<DateRangePicker3>", () => {
});
});

describe("outside days", () => {
it("visually hides outside days when contiguous months are shown, even if showOutsideDays is true", () => {
const warnSpy = stub(console, "warn");
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Might be useful to clean up this stub at the end of this function with:

warnSpy.restore();

Otherwise this console.warn stub stucks around for all tests that run after this one.


/* stylelint-disable max-line-length */
&.#{$ns}-datepicker.#{$ns}-daterangepicker-single-month.#{$ns}-daterangepicker-showing-outside-days .rdp-day_outside {
pointer-events: none; // weird interactions happen if allowing outside days to be clicked
Copy link
Contributor

Choose a reason for hiding this comment

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

I would be curious for @alex-dales's opinion. Playing around with the UI, I actually found it surprising that I couldn't click on the grayed out dates. It might not be obvious to some users that they have to switch to the previous month intentionally to select these "outside day" dates?

<Tooltip content="Only respected when showing a single month calendar">
<Switch
checked={this.state.showOutsideDays}
className="keep-bottom-margin"
Copy link
Contributor

Choose a reason for hiding this comment

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

super nitpick: It looks like the bottom margin here is getting reset back to 0 by some other CSS selector.

Screenshot 2024-08-06 at 6 08 13 PM

@svc-palantir-github
Copy link

assert warn

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DateRangePicker singleMonthOnly does not support showing "outside" days
3 participants