Skip to content

Perf: Optimize DomAccess.syncAligns to avoid scroll thrashing #9050

@tobiu

Description

@tobiu

Neo.main.DomAccess.syncAligns triggers a full realignment cycle on every scroll event. This can cause significant layout thrashing (performance "hammering"), especially when scrolling inside a floating container (like a Picker's list) that is itself aligned to another element.

Goal:
Optimize syncAligns to filter scroll events. It should only trigger re-alignment if the scrolling element is an ancestor of the alignment target or the constraint element. If the scroll event originates from within the aligned component itself (or an unrelated container), the alignment logic should be skipped.

Implementation Plan:

  1. Modify syncAligns in src/main/DomAccess.mjs.
  2. Check if the event type is scroll.
  3. If it is, verify if the event.target contains the align.targetElement or align.constrainToElement.
  4. If neither is contained, return early and skip align().

This will prevent unnecessary calculations and DOM read/writes during scrolling interactions within floating components.

Metadata

Metadata

Assignees

Labels

aicoreCore framework functionalityperformancePerformance improvements and optimizations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions