Skip to content

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

Open
vJIYEv wants to merge 4 commits into
release/1.9.x.developfrom
feature/NXT-15051
Open

NXT-15051: Fixed focus jump and scroll freeze in VirtualList when scrolled by long press#361
vJIYEv wants to merge 4 commits into
release/1.9.x.developfrom
feature/NXT-15051

Conversation

@vJIYEv
Copy link
Copy Markdown
Contributor

@vJIYEv vJIYEv commented Jun 1, 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)

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.70%. Comparing base (dce1c67) to head (2508d96).
⚠️ Report is 6 commits behind head on release/1.9.x.develop.

Files with missing lines Patch % Lines
VirtualList/useEvent.js 96.29% 1 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##           release/1.9.x.develop     #361      +/-   ##
=========================================================
+ Coverage                  81.61%   81.70%   +0.08%     
=========================================================
  Files                        153      153              
  Lines                       7317     7341      +24     
  Branches                    2212     2220       +8     
=========================================================
+ Hits                        5972     5998      +26     
+ Misses                      1039     1037       -2     
  Partials                     306      306              

☔ 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