Skip to content

Commit

Permalink
fix: use the most recent IntersectionObserver entry in form-layout (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Jan 31, 2025
1 parent 100f4d1 commit f047f75
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit f047f75

Please sign in to comment.