-
Notifications
You must be signed in to change notification settings - Fork 1
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
DatePicker: Date selection/highlighting fixes #44
Conversation
This is now redundant, since arrow keys immediately emit the selected date. The effect is that in other contexts (ex: when navigating using the prev/next links), when enter is pressed it selects the highlighted date in addition to any other action that it would normally do.
…"current" class logic
@@ -267,7 +267,7 @@ | |||
classes.push('default'); | |||
} | |||
|
|||
if (selectionMode === 'day' && (cell.type === 'normal' || cell.type === 'today') && this.cellMatchesDate(cell, this.date || this.value)) { | |||
if (selectionMode === 'day' && (cell.type === 'normal' || cell.type === 'today') && this.cellMatchesDate(cell, this.value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.date
so that the "is-selected" class is only determined by the persisted value of the component.
@@ -462,9 +462,6 @@ | |||
event.stopPropagation(); | |||
event.preventDefault(); | |||
} | |||
if (keyCode === 13 && this.userInputDate === null && this.userInputTime === null) { // Enter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this old, obsolete Enter key behavior.
This PR addresses inconsistencies in the way that "selected" dates are highlighted in the date picker calendar. The component's internal
date
property is used to drive a lot of behavior, but it doesn't always correspond to the component's "persisted" value (i.e. thevalue
prop), and this can lead to some misleading styling. For example, when the picker is opened with no value, the default (ex: current date) is flagged as "selected", even though it isn't actually the current value, and if the picker is closed it won't be persisted. Also, in that case, when navigating to previous/next months and years, another date is marked as "selected", which is also not the persisted value. To address this, don't take into account thedate
data property when adding the class for the selected date.Related: Don't select a date and emit the event when Enter key is pressed. This behavior was added when arrow key controls were implemented, however, since then it has been changed such that arrow keys immediately emit the new value. So, the enter key behavior only has the effect of choosing the non-persisted date in other, unexpected scenarios, ex: after navigating to prev/next months or years.