Skip to content

Commit d05802e

Browse files
authored
Use overflow-anchor as a better fix for scrolling behaviour (#48)
Our hack for this caused issues when programatically setting the offset with a smooth scroll. This is the corect fix!
1 parent b35e5cc commit d05802e

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

lib/tables.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,6 @@ class Table<T> extends Object with SetStateMixin {
205205
}
206206

207207
void _rebuildVirtualTable() {
208-
// When we modify the height of the spacer above the viewport, Chrome automatically
209-
// adjusts the scrollTop to compensate because it's trying to keep the same content
210-
// visible to the user. However, since we're overwriting the rows contents (shifting
211-
// the data in the rows) we want to retain the original scroll position so must stash
212-
// it and reset it later.
213-
final int originalScrollTop = element.scrollTop;
214-
215208
int firstRenderedRowInclusive = 0;
216209
int lastRenderedRowExclusive = data?.length ?? 0;
217210

@@ -273,10 +266,6 @@ class Table<T> extends Object with SetStateMixin {
273266
(data.length - lastRenderedRowExclusive) * rowHeight;
274267
_spacerAfterVisibleRows.height = '${spacerAfterHeight}px';
275268
_tbody.element.children.add(_spacerAfterVisibleRows.element);
276-
277-
// Restore the scroll position the user had scrolled to since Chrome may
278-
// have modified it after we changed the height of the "before" spacer.
279-
element.scrollTop = originalScrollTop;
280269
}
281270

282271
void _rebuildStaticTable() => _buildTableRows(

web/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ span.label.gc {
112112
background-color: #424242;
113113
}
114114

115+
.table-virtual {
116+
overflow-anchor: none;
117+
}
118+
115119
.table-virtual td {
116120
max-width: 500px; /* required for text-overflow to work? */
117121
overflow: hidden;

0 commit comments

Comments
 (0)