From 76c794992c1e3e0494471daa2af2c657788f4c1e Mon Sep 17 00:00:00 2001 From: Tomi Virkki Date: Tue, 22 Sep 2020 17:43:03 +0300 Subject: [PATCH] fix: workaround a Safari sticky positioning issue with disappearing header --- src/vaadin-grid-scroll-mixin.html | 8 ++++++++ test/basic.html | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/vaadin-grid-scroll-mixin.html b/src/vaadin-grid-scroll-mixin.html index 60f7fc0df..11941c7aa 100644 --- a/src/vaadin-grid-scroll-mixin.html +++ b/src/vaadin-grid-scroll-mixin.html @@ -321,6 +321,14 @@ body.insertBefore(items[i], items[0]); } } + + // Due to a rendering bug, reordering the rows can make the sticky header disappear on Safari + // if the grid is used inside of a flex box. This is a workaround for the issue. + if (this._safari) { + const {transform} = this.$.header.style; + this.$.header.style.transform = ''; + setTimeout(() => this.$.header.style.transform = transform); + } } /** @protected */ diff --git a/test/basic.html b/test/basic.html index a4324de10..fece0150e 100644 --- a/test/basic.html +++ b/test/basic.html @@ -352,6 +352,15 @@ expect(grid.$.scroller.getBoundingClientRect().width).to.be.closeTo(300 - 2, 1); }); + it('should have a visible header after row reorder', () => { + grid.querySelector('vaadin-grid-column').header = 'header'; + grid.scrollToIndex(300); + flushGrid(grid); + const {left, top} = grid.getBoundingClientRect(); + const cell = grid._cellFromPoint(left + 1, top + 1); + expect(grid.$.header.contains(cell)).to.be.true; + }); + // Skip this test on iOS 10 since there Safari has a bug that makes this fail (works in iOS 9, 11 and 12) (/iPhone OS 10_/.test(navigator.userAgent) ? it.skip : it)('should stretch height', () => { expect(grid.getBoundingClientRect().height).to.be.closeTo(200, 1);