Skip to content

Commit 809ed04

Browse files
committed
fix(Calendar): only apply disabled/selected states for week selection type
1 parent 85c1154 commit 809ed04

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

js/src/calendar.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -875,23 +875,35 @@ class Calendar extends BaseComponent {
875875
}
876876

877877
_rowWeekAttributes(date) {
878+
if (this._config.selectionType !== 'week') {
879+
return {
880+
className: this._classNames({ [CLASS_NAME_CALENDAR_ROW]: true }),
881+
tabIndex: -1,
882+
ariaSelected: false
883+
}
884+
}
885+
878886
const isDisabled = isDateDisabled(date, this._minDate, this._maxDate, this._config.disabledDates)
879887
const isSelected = isDateSelected(date, this._startDate, this._endDate)
888+
const isInRange = isDateInRange(date, this._startDate, this._endDate)
889+
890+
const isRangeHover = this._hoverDate && (
891+
this._selectEndDate ?
892+
isYearInRange(date, this._startDate, this._hoverDate) :
893+
isYearInRange(date, this._hoverDate, this._endDate)
894+
)
880895

881896
const classNames = this._classNames({
882897
[CLASS_NAME_CALENDAR_ROW]: true,
883898
disabled: isDisabled,
884-
range: this._config.selectionType === 'week' && isDateInRange(date, this._startDate, this._endDate),
885-
'range-hover': this._config.selectionType === 'week' &&
886-
(this._hoverDate && this._selectEndDate ?
887-
isYearInRange(date, this._startDate, this._hoverDate) :
888-
isYearInRange(date, this._hoverDate, this._endDate)),
899+
range: isInRange,
900+
'range-hover': isRangeHover,
889901
selected: isSelected
890902
})
891903

892904
return {
893905
className: classNames,
894-
tabIndex: this._config.selectionType === 'week' && !isDisabled ? 0 : -1,
906+
tabIndex: isDisabled ? -1 : 0,
895907
ariaSelected: isSelected
896908
}
897909
}

0 commit comments

Comments
 (0)