Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ensure Lit month calendars are rendered synchronously #8220

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor Author

@vursen vursen Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Some tests finish before the _finishInit handler is executed. In such cases, we need to cancel its execution to prevent performUpdate from throwing an exception.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should also consider updating these tests to wait for overlay open.

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