Skip to content

fix: prevent 'Go one folder up' from changing editor selection#1856

Merged
willeastcott merged 1 commit intomainfrom
fix/navigate-back-no-selection-change
Mar 3, 2026
Merged

fix: prevent 'Go one folder up' from changing editor selection#1856
willeastcott merged 1 commit intomainfrom
fix/navigate-back-no-selection-change

Conversation

@willeastcott
Copy link
Contributor

Summary

  • Fix the "Go one folder up" button in the Assets panel so it only moves the active/current folder highlight to the parent folder without changing the editor's asset selection.

Details

navigateBack() calls _focusAssetItem() after filtering completes to scroll the previous folder into view. However, _focusAssetItem also sets selected = true on the grid/table item, which triggers _onSelectAssetElementeditor.call('selector:add', ...), modifying the editor's selection as a side effect.

The fix wraps the _focusAssetItem call with _suspendSelectEvents = true so the item is still focused and scrolled into view, but the selector is not modified.

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
@vercel
Copy link

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
editor Building Building Preview, Comment Mar 3, 2026 7:29pm

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 _suspendSelectEvents block when filter:end fires during navigateBack().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2497 to +2499
this._suspendSelectEvents = true;
this._focusAssetItem(prevFolderId);
this._suspendSelectEvents = false;
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
this._suspendSelectEvents = true;
this._focusAssetItem(prevFolderId);
this._suspendSelectEvents = false;
const prevSuspend = this._suspendSelectEvents;
this._suspendSelectEvents = true;
try {
this._focusAssetItem(prevFolderId);
} finally {
this._suspendSelectEvents = prevSuspend;
}

Copilot uses AI. Check for mistakes.
@willeastcott willeastcott merged commit 3411795 into main Mar 3, 2026
14 of 15 checks passed
@willeastcott willeastcott deleted the fix/navigate-back-no-selection-change branch March 3, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants