Skip to content

Fix: Reduce selection lag during drag selection by throttling SelectionChanged events#18290

Open
LeoAndJellyfish wants to merge 1 commit intofiles-community:mainfrom
LeoAndJellyfish:main
Open

Fix: Reduce selection lag during drag selection by throttling SelectionChanged events#18290
LeoAndJellyfish wants to merge 1 commit intofiles-community:mainfrom
LeoAndJellyfish:main

Conversation

@LeoAndJellyfish
Copy link
Copy Markdown

Resolved / Related Issues

Summary of Changes

Introduced a selection update timer to reduce the frequency of SelectionChanged events during drag selection, improving performance through batched selection updates.

Key Changes:

  • Added selectionUpdateTimer with 8ms interval (~120fps)
  • Added pendingSelectedItems and pendingRemovedItems lists to buffer pending changes
  • Unified selection state updates when the timer triggers
  • Ensured correct final selection state when pointer is released
  • Accumulated removed items to prevent state loss during rapid dragging

Technical Details:

  • Uses DispatcherQueueTimer for 8ms throttling interval
  • Accumulates pendingRemovedItems to ensure all selection changes are correctly processed during rapid dragging
  • Batch triggers SelectionChanged event in timer callback

Steps used to test these changes

  1. Opened Files and navigated to a folder with many files (100+)
  2. Performed drag selection (box selection) across multiple files
  3. Verified smooth selection updates during drag
  4. Verified correct final selection state after releasing pointer
  5. Tested rapid drag selection to ensure no selection state is lost
  6. Tested with Ctrl+drag (invert selection) and Shift+drag (extend selection)

引入选择更新定时器以减少在拖动选择时频繁触发SelectionChanged事件,通过批量处理选择更新提升性能。新增pendingSelectedItems和pendingRemovedItems列表暂存待处理项,并在定时器触发时统一处理。
@yair100 yair100 added the ready for review Pull requests that are ready for review label Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Pull requests that are ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Lag when drag selecting multiple items due to frequent SelectionChanged events

2 participants