Skip to content

Commit

Permalink
Add comment and test re not dispatching event initially.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbatiste committed Sep 25, 2024
1 parent 67875d6 commit 07d4fd1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ class Calendar extends LocalizeCoreElement(RtlMixin(LitElement)) {
willUpdate(changedProperties) {
super.willUpdate(changedProperties);

// don't dispatch d2l-calendar-view-change when _shownYear and _shownMonth are being initialized
if (changedProperties.get('_shownYear') === undefined && changedProperties.get('_shownMonth') === undefined) return;

const dates = getDatesInMonthArray(this._shownMonth, this._shownYear);
Expand Down
9 changes: 9 additions & 0 deletions components/calendar/test/calendar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ describe('d2l-calendar', () => {
expect(detail.maxValue).to.deep.equal(new Date(2015, 9, 31));
});

it('does not dispatch d2l-calendar-view-change event initially', async() => {
let dispatched = false;
const calendar = document.createElement('d2l-calendar');
calendar.addEventListener('d2l-calendar-view-change', () => dispatched = true);
document.body.appendChild(calendar);
await calendar.updateComplete;
expect(dispatched).to.equal(false);
});

});

describe('focus date', () => {
Expand Down

0 comments on commit 07d4fd1

Please sign in to comment.