Skip to content

Commit

Permalink
fix: render at most 7 weekdays in date picker (#7542) (#7544)
Browse files Browse the repository at this point in the history
Co-authored-by: Fredi Wasström <fredrik.wasstrom@gmail.com>
  • Loading branch information
vaadin-bot and FrediWa authored Jul 12, 2024
1 parent de6cabb commit 328b39c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/date-picker/src/vaadin-month-calendar-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ export const MonthCalendarMixin = (superClass) =>
const weekDayNamesShort = this._applyFirstDayOfWeek(weekdaysShort, firstDayOfWeek);
const weekDayNames = this._applyFirstDayOfWeek(weekdays, firstDayOfWeek);

return weekDayNames.map((day, index) => {
return {
weekDay: day,
weekDayShort: weekDayNamesShort[index],
};
});
return weekDayNames
.map((day, index) => {
return {
weekDay: day,
weekDayShort: weekDayNamesShort[index],
};
})
.slice(0, 7);
}

/** @private */
Expand Down
12 changes: 12 additions & 0 deletions packages/date-picker/test/month-calendar.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ describe('vaadin-month-calendar', () => {
expect(monthCalendar.shadowRoot.querySelector('[part="month-header"]').textContent).to.equal('January 2000');
});

it('should render at most 7 weekdays', async () => {
monthCalendar.i18n = {
...monthCalendar.i18n,
weekdays: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
weekdaysShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
};
await nextRender();

const weekdays = getWeekDayCells(monthCalendar);
expect(weekdays.length).to.equal(7);
});

it('should fire value change on tap', () => {
const dateElements = getDateCells(monthCalendar);
tap(dateElements[10]);
Expand Down

0 comments on commit 328b39c

Please sign in to comment.