Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: workaround a Safari sticky positioning issue with disappearing header #1799

Merged
merged 2 commits into from
Sep 23, 2020
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
8 changes: 8 additions & 0 deletions src/vaadin-grid-scroll-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
12 changes: 12 additions & 0 deletions src/vaadin-grid.html
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,18 @@
this.$.items.style.paddingBottom = `${this.$.footer.offsetHeight}px`;
}
}

if (this._ios) {
const isOldIOS = !window.CSS.supports('position', 'sticky');
if (isOldIOS) {
// Due to a rendering bug, the sticky header may disappear on an older iOS (10-12) Safari
// if the grid is used inside of a flex box. This is a workaround for the issue.
this.$.table.style.height = '';
this.$.table.style.minHeight = '100%';
this.$.table.style.maxHeight = '100%';
setTimeout(() => this.$.table.style.height = `${this.$.scroller.offsetHeight}px`);
}
}
}

/**
Expand Down
12 changes: 12 additions & 0 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,18 @@
expect(grid.$.scroller.getBoundingClientRect().width).to.be.closeTo(300 - 2, 1);
});

it('should have a visible header after row reorder', done => {
grid.querySelector('vaadin-grid-column').header = 'header';
grid.scrollToIndex(300);
setTimeout(() => {
flushGrid(grid);
const {left, top} = grid.getBoundingClientRect();
const cell = grid._cellFromPoint(left + 1, top + 1);
expect(grid.$.header.contains(cell)).to.be.true;
done();
});
});

// 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);
Expand Down