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

fix: use the most recent IntersectionObserver entry in form-layout #8596

Merged
merged 1 commit into from
Jan 31, 2025
Merged
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
7 changes: 6 additions & 1 deletion packages/form-layout/src/vaadin-form-layout-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ export const FormLayoutMixin = (superClass) =>
// Ensure there is a child text node in the style element
this._styleElement.textContent = ' ';

this.__intersectionObserver = new IntersectionObserver(([entry]) => {
this.__intersectionObserver = new IntersectionObserver((entries) => {
// If the browser is busy (e.g. due to slow rendering), multiple entries can
// be queued and then passed to the callback invocation at once. Make sure we
// use the most recent entry to detect whether the layout is visible or not.
// See https://github.com/vaadin/web-components/issues/8564
const entry = [...entries].pop();
if (!entry.isIntersecting) {
// Prevent possible jump when layout becomes visible
this.$.layout.style.opacity = 0;
Expand Down