Skip to content

NO-1497: Improve table modal scroll performance - #400

Closed
vivekjyani wants to merge 1 commit into
mainfrom
NO-1497
Closed

vivekjyani wants to merge 1 commit into
mainfrom
NO-1497

Conversation

@vivekjyani

@vivekjyani vivekjyani commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Context

The table modal grid scrolled sluggishly with large row counts. Profiling showed every row was being materialized on load (no virtualization), and the SwiftUI body re-evaluated on every scroll frame because the sticky header and left row-number column were kept in sync through @State-driven offsets.

What changed

Single file: Sources/JoyfillUI/View/Fields/TableView/TableModalView.swift

  • Restored LazyVStack virtualization by removing .fixedSize(horizontal: false, vertical: true) from the grid stack — it forced the stack to its full ideal height, eagerly building every row. Now only visible rows are built.
  • Replaced the manual offset sync (ViewOffsetKey preference + @State offset) with UIKit contentOffset KVO. A small TableScrollSync handle + TableGridScrollReader/TableScrollCapture mirror the grid's scroll offset onto the left row-number column (y) and column header (x) on the render thread — off the SwiftUI update path.
  • Extracted leftCornerHeader, columnsHeader, and a TableRowNumbersColumn view; collapsed the duplicated iOS 15/16 branches.

Decisions

  • KVO over a @State-driven offset. Driving the header/left column from the grid's contentOffset in UIKit keeps the sync on the render thread, so steady-state scrolling no longer re-evaluates the modal body each frame.
  • TableScrollSync is a plain class held in @State (not ObservableObject) so mutating the captured scroll views never invalidates the body.
  • .scrollDisabled(true) on iOS 16+ (programmatic contentOffset still works); drag-blocking gesture fallback on iOS 15.

Media

Public API / docs

No public API change — all new types (TableScrollSync, TableGridScrollReader, TableScrollCapture, TableRowNumbersColumn) are internal/private. No docs update needed.

Tests

Full unit suite passes (2334/2334). Scroll smoothness verified manually on-device. No new unit tests — this is a view-layer change not covered by the unit harness; existing table UI tests exercise the accessibility identifiers, all of which are preserved.

Reviewer notes

Behavior is intended to be identical to before apart from the scroll performance improvement. All accessibility identifiers, selection, filter/sort, pencil→edit-sheet, and scrollTo behavior are unchanged.

@vivekjyani vivekjyani changed the title NO-1497: Fix table modal scroll performance & text cell editing NO-1497: Fix table modal scroll performance Oct 20, 2026
@vivekjyani vivekjyani changed the title NO-1497: Fix table modal scroll performance NO-1497: Improve table modal scroll performance Oct 20, 2026
@vivekjyani vivekjyani closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant