fix(ui5-daypicker): date selection range light blue indication #6836
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
When selecting a date range in the Calendar with selection mode Range, if you select a new start date (and thus have only one date selected), a range of dates have their background color set to light blue indicating they are in the selected date range. This is incorrect since there is only one date selected and therefore no date range yet.
Issue
The problem is that the DayPicker that the Calendar implements has a property called
_secondTimestamp
that keeps track of the current date that the mouse is hovering (for selection mode Range). When a single date is selected, this allows the DayPicker to update the dates between the selected date and the current date hovered by the mouse (or focused) to have a light blue background color. DayPicker also updates_secondTimestamp
to thetimestamp
property, which is the current selected date, when only one date was previously selected and a new date is selected. But when two dates were previously selected and a new date is selected,_secondTimestamp
is not updated totimestamp
. Thus, when two dates were previously selected and a new date is selected, dates between the new date and_secondTimestamp
which did not update to the new date are marked in light blue._secondTimestamp
due to 9 being the last date hovered before a second date was chosen) to 20 are light blue.Change
In order to fix this,
_secondTimestamp
needs to be updated to the currenttimestamp
property when a new start date is selected. This is done by changing the_updateSecondTimestamp
method (called when a new date is selected) to update the_secondTimestamp
to the currenttimestamp
when there were previously two dates already selected. Previously,_updateSecondTimestamp
only updated_secondTimestamp
to the currenttimestamp
when there was previously one date already selected.Fixes #6781
Pull Request Checklist