Skip to content

NXT-15051: Fixed focus jump and scroll freeze in VirtualList when scrolled by long press#362

Open
vJIYEv wants to merge 2 commits into
developfrom
feature/NXT-15051-develop
Open

NXT-15051: Fixed focus jump and scroll freeze in VirtualList when scrolled by long press#362
vJIYEv wants to merge 2 commits into
developfrom
feature/NXT-15051-develop

Conversation

@vJIYEv
Copy link
Copy Markdown
Contributor

@vJIYEv vJIYEv commented Jun 2, 2026

Checklist

  • I have read and understand the contribution guide
  • A CHANGELOG entry is included
  • At least one test case is included for this feature or bug fix
  • Documentation was added or is not needed
  • This is an API breaking change

Issue Resolved / Feature Added

During key long press in VirtualList, focus jumped backward and scrolling froze permanently.

Resolution

This occurred because VirtualList recycles DOM nodes during scroll — when a recycled node's data-index was read as the event target index, the key handler detected an anomaly and silently discarded the event. With each subsequent repeat event discarded the same way, scrolling halted indefinitely.

A secondary issue: when focus entered a VirtualList while a key was already held (e.g., held before panel transition), the first event had repeat: true, causing focus to skip item 0 immediately.

  1. useEvent.js
  • prevKeyDownIndex was a module-level let variable shared across all VirtualList instances. Replaced with per-instance prevKeyDownIndexRef and hasProcessedKeyDownRef (useRef) to eliminate cross-instance state pollution.
  • isOutdatedIndex detects when data-index on the focused DOM node jumped unnaturally during repeat (recycling artifact). Instead of silently returning, now calls handleDirectionKeyDown with a corrected next index derived from prevKeyDownIndexRef, then advances the ref. This resumes scroll continuity rather than freezing.
  • isFirstEntryRepeat detects repeat: true on the very first keydown after entering the list (hasProcessedKeyDownRef is still false). Blocks and resets the accelerator so focus stays on the entry item.
  • resetAccelerator is now destructured from context so both new code paths can reset SpotlightAccelerator on early return.
  1. useThemeVirtualList.js
  • Added resetAccelerator callback to the context object passed to useEventKey, delegating to SpotlightAccelerator.reset().

Additional Considerations

Links

NXT-15051

Comments

Enact-DCO-1.0-Signed-off-by: Jiye Kim (jiye.kim@lge.com)

…olled by long press

Enact-DCO-1.0-Signed-off-by: Jiye Kim (jiye.kim@lge.com)
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.05%. Comparing base (4387fb1) to head (afe20d5).

Files with missing lines Patch % Lines
VirtualList/useEvent.js 96.29% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #362      +/-   ##
===========================================
+ Coverage    81.97%   82.05%   +0.07%     
===========================================
  Files          153      153              
  Lines         7480     7502      +22     
  Branches      2251     2258       +7     
===========================================
+ Hits          6132     6156      +24     
+ Misses        1043     1041       -2     
  Partials       305      305              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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