fix: prevent 'Go one folder up' from changing editor selection#1856
fix: prevent 'Go one folder up' from changing editor selection#1856willeastcott merged 1 commit intomainfrom
Conversation
The navigateBack() method was calling _focusAssetItem() after filtering,
which set selected = true on the previous folder's grid/table item. This
triggered _onSelectAssetElement and editor.call('selector:add'), changing
the editor's selection as a side effect.
Wrap the _focusAssetItem call with _suspendSelectEvents so the item is
still focused and scrolled into view but the selector is not modified.
Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Fixes Assets panel “Go one folder up” navigation so the parent folder is focused/scrolled into view without mutating the editor’s asset selection via selection event side effects.
Changes:
- Wrap
_focusAssetItem(prevFolderId)in a temporary_suspendSelectEventsblock whenfilter:endfires duringnavigateBack().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| this._suspendSelectEvents = true; | ||
| this._focusAssetItem(prevFolderId); | ||
| this._suspendSelectEvents = false; |
There was a problem hiding this comment.
This temporarily forces _suspendSelectEvents to false after focusing, which can break callers that already had selection events suspended when filter:end fires (nested/overlapping suspensions). Capture the previous value and restore it (ideally in a try/finally) so this callback doesn’t inadvertently re-enable select events.
| this._suspendSelectEvents = true; | |
| this._focusAssetItem(prevFolderId); | |
| this._suspendSelectEvents = false; | |
| const prevSuspend = this._suspendSelectEvents; | |
| this._suspendSelectEvents = true; | |
| try { | |
| this._focusAssetItem(prevFolderId); | |
| } finally { | |
| this._suspendSelectEvents = prevSuspend; | |
| } |
Summary
Details
navigateBack()calls_focusAssetItem()after filtering completes to scroll the previous folder into view. However,_focusAssetItemalso setsselected = trueon the grid/table item, which triggers_onSelectAssetElement→editor.call('selector:add', ...), modifying the editor's selection as a side effect.The fix wraps the
_focusAssetItemcall with_suspendSelectEvents = trueso the item is still focused and scrolled into view, but the selector is not modified.