Skip to content

Commit 5b2ea21

Browse files
vaadin-botFrediWa
andauthored
fix: render at most 7 weekdays in date picker (#7542) (#7545)
Co-authored-by: Fredi Wasström <fredrik.wasstrom@gmail.com>
1 parent 44836c8 commit 5b2ea21

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

packages/date-picker/src/vaadin-month-calendar-mixin.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,14 @@ export const MonthCalendarMixin = (superClass) =>
188188
const weekDayNamesShort = this._applyFirstDayOfWeek(weekdaysShort, firstDayOfWeek);
189189
const weekDayNames = this._applyFirstDayOfWeek(weekdays, firstDayOfWeek);
190190

191-
return weekDayNames.map((day, index) => {
192-
return {
193-
weekDay: day,
194-
weekDayShort: weekDayNamesShort[index],
195-
};
196-
});
191+
return weekDayNames
192+
.map((day, index) => {
193+
return {
194+
weekDay: day,
195+
weekDayShort: weekDayNamesShort[index],
196+
};
197+
})
198+
.slice(0, 7);
197199
}
198200

199201
/** @private */

packages/date-picker/test/month-calendar.common.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ describe('vaadin-month-calendar', () => {
6464
expect(monthCalendar.shadowRoot.querySelector('[part="month-header"]').textContent).to.equal('January 2000');
6565
});
6666

67+
it('should render at most 7 weekdays', async () => {
68+
monthCalendar.i18n = {
69+
...monthCalendar.i18n,
70+
weekdays: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
71+
weekdaysShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
72+
};
73+
await nextRender();
74+
75+
const weekdays = getWeekDayCells(monthCalendar);
76+
expect(weekdays.length).to.equal(7);
77+
});
78+
6779
it('should fire value change on tap', () => {
6880
const dateElements = getDateCells(monthCalendar);
6981
tap(dateElements[10]);

0 commit comments

Comments
 (0)