-
Notifications
You must be signed in to change notification settings - Fork 68
Provide a way to disable days #52
Provide a way to disable days #52
Conversation
This is great! 🥳 Can we get this to 1.2 beta? 😄 |
This looks good to me! Are there any plans to add this? |
I'll try to take a look at this later this week. I have a lot going on at the moment, so can't dedicate much time. On top of reviewing the code, I'll need to test how this behaves using keyboard and in various screen reader/browser combos. So it's not a quick merge unfortunately! Thanks for making the PR @bseber |
I tested this today, and I immediately hit issues when navigating dates using the keyboard. The focus marker is not visible when you navigate to a disabled date, so it is not clear to the user what is happening. I don't have time to test this further today, I'll need do some more investigation another time |
5f50bd1
to
071cc2f
Compare
🤔 That's a tricky one we could highlight disabled days with &:focus,
&.is-disabled[tabindex="0"] {
box-shadow: 0 0 5px var(--duet-color-primary);
z-index: 200;
} To remove the focused style from the previously selected day, however, we have to blur it manually within the if (document.activeElement instanceof HTMLElement) {
document.activeElement.blur()
} which in turn breaks the keyboard navigation since there is no focused element anymore.
what do you think about this idea? |
I was thinking of maybe using aria-disabled for those dates? Then they could still be focusable etc, but it would be presented as disabled to screen readers. I need to give it some more thought |
Good morning @WickyNilliams, this would be a great feature for us. Can I help you to get this faster into a release? |
We're itching to get at this feature as well. Please let us know if there is anything we can do to help 😄 |
make `isDateDisabled` optional to not introduce a breaking change
enabling selection of every visible day in the date picker should have no impact on the visualization. days of next or previous month could be selectable but should still be rendered differently to the focused month.
071cc2f
to
1000f33
Compare
@WickyNilliams I rebased on |
@bseber thanks, this looks good at a glance! I will do some testing later this week. There are a few small changes I would suggest, though i'm happy to make them myself before publishing a new version, to save on some back and forth. Unless you'd like to do it! Happy to list my suggestions if so. Let me know. |
Also, forgot to say, I really appreciate the tests! |
feel free to do the small changes yourself :-) |
Initial testing seems like this works really well.
I will now merge and make some changes myself. The changes i'm going to make:
|
Also i want to simplify things so that isDateDisabled can look like this: picker.isDateDisabled = function isWeekend(date) {
return date.getDay() === 0 || date.getDay() === 6;
} Rather than this: picker.isDateDisabled = function isWeekendPlusSomeOtherLogicSadFace(date, focusedDay) {
return (
date.getDay() === 0 ||
date.getDay() === 6 ||
!(date.getFullYear() === focusedDay.getFullYear() && date.getMonth() === focusedDay.getMonth())
)
} Working with the focused day and handling current year/month stuff should not be the developer's concern, this logic will always be required, so the picker should handle it :) |
dateAdapter.isDateDisabled
closes #15