Skip to content

Commit

Permalink
refactor: ensure Lit month calendars are rendered synchronously (#8220)
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen authored Nov 25, 2024
1 parent 5163e29 commit d954c55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const DatePickerOverlayContentMixin = (superClass) =>
initialPosition: {
type: Object,
observer: '_initialPositionChanged',
sync: true,
},

_originDate: {
Expand Down
22 changes: 21 additions & 1 deletion packages/date-picker/src/vaadin-infinite-scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ export class InfiniteScroller extends HTMLElement {
}
}

/** @protected */
disconnectedCallback() {
if (this._debouncerScrollFinish) {
this._debouncerScrollFinish.cancel();
}

if (this._debouncerUpdateClones) {
this._debouncerUpdateClones.cancel();
}

if (this.__pendingFinishInit) {
cancelAnimationFrame(this.__pendingFinishInit);
}
}

/**
* Force the scroller to update clones after a reset, without
* waiting for the debouncer to resolve.
Expand Down Expand Up @@ -348,8 +363,9 @@ export class InfiniteScroller extends HTMLElement {
}
});

requestAnimationFrame(() => {
this.__pendingFinishInit = requestAnimationFrame(() => {
this._finishInit();
this.__pendingFinishInit = null;
});
}

Expand All @@ -364,6 +380,10 @@ export class InfiniteScroller extends HTMLElement {
itemWrapper.instance = this._createElement();
itemWrapper.appendChild(itemWrapper.instance);

if (itemWrapper.instance.performUpdate) {
itemWrapper.instance.performUpdate();
}

Object.keys(tmpInstance).forEach((prop) => {
itemWrapper.instance[prop] = tmpInstance[prop];
});
Expand Down

0 comments on commit d954c55

Please sign in to comment.