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 Feb 3, 2025
1 parent 9e0c949 commit 986baf9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/form-layout/src/vaadin-form-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,12 @@ class FormLayout extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))
constructor() {
super();

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 986baf9

Please sign in to comment.