Skip to content

perf(grid): rebuild on horizontal scroll only when the visible column window changes (#879) - #971

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/879-grid-horizontal-scroll-no-setstate
Sep 25, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
issue/879-grid-horizontal-scroll-no-setstate

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Описание изменений

  • _onHorizontalScroll делал setState на каждые 0.5 px сдвига, из-за чего на широкой таблице перестраивалось всё виртуализированное тело на каждом кадре панорамирования.
  • Горизонтальный SingleChildScrollView уже сам сдвигает шапку и тело вместе, а _scrollOffset нужен только для выбора построенных колонок (виртуализация по колонкам). Поэтому теперь по смещению пересчитывается окно колонок (computeVisibleColumnWindow) по данным последнего build (_currentDisplayWidths, _currentWindow), и setState вызывается только если окно изменилось. Иначе смещение просто запоминается.
  • Ширины, разметка и поведение при смене окна прежние (окно с overscan).
  • Тесты в result_grid_sorting_model_test.dart (3 новых): небольшой сдвиг внутри окна не пересоздаёт строки (проверяется идентичность виджета строки, тест падает на старом коде), сдвиг до конца строит новые колонки, возврат назад восстанавливает первые. Весь файл прогнал локально, 13 проходят.

Не входит

Автоподбор ширины колонок в LayoutBuilder (как в issue). Замер FPS при 120 Hz не делал.

Связанные Issue

Closes #879

… window changes (Closes #879)

_onHorizontalScroll called setState for every 0.5px of movement, rebuilding the
whole virtualized body on each pan frame of a wide grid.

The horizontal scroll view already translates header and body together; the
offset only decides which columns are built. Recompute the visible column window
from the last build's widths and rebuild only when it differs, otherwise just
remember the offset.
@github-actions github-actions Bot added frontend Theme parser epic label: frontend performance Theme parser epic label: performance data-grid Interactive data grid, cell editor, filtering, groupings labels Sep 25, 2026
@github-actions github-actions Bot added this to the 0.4.18 milestone Sep 25, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 36ab249 into dev Sep 25, 2026
4 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the issue/879-grid-horizontal-scroll-no-setstate branch September 28, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data-grid Interactive data grid, cell editor, filtering, groupings frontend Theme parser epic label: frontend performance Theme parser epic label: performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant