[Peek] Fix Space key triggering during file rename (#44845)#44995
[Peek] Fix Space key triggering during file rename (#44845)#44995
Conversation
Don't show error window when CurrentItem is null - just return silently. This restores the original behavior where CaretVisible() detection in GetSelectedItems() would suppress Peek by returning null, and no window would be shown. PR #44703 added an error window for virtual folders (Home/Recent), but this also triggered when user was typing (rename, search, address bar), stealing focus and cancelling the operation. Fixes #44845
There was a problem hiding this comment.
Pull request overview
Adjusts Peek’s activation flow so it no longer shows an error window when no item is selected (e.g., during in-place rename / search typing), preventing focus-stealing that cancels the user’s operation.
Changes:
- Stops showing the “No files selected…” error UI when
ViewModel.CurrentItemis null. - Returns silently from initialization when no preview item is available.
| // If no files were found (e.g., user is typing in rename/search box, or in virtual folders), | ||
| // don't show anything - just return silently to avoid stealing focus | ||
| if (ViewModel.CurrentItem == null) | ||
| { |
There was a problem hiding this comment.
Returning early when ViewModel.CurrentItem is null leaves the window in whatever state it was in. In particular, the first activation path calls Activate() before Initialize(), so this branch can still result in an activated/visible (but empty) Peek window and focus being stolen. Consider explicitly hiding/uninitializing the window in this branch, or restructuring so the window is only activated/shown once a non-null CurrentItem is confirmed.
| { | |
| { | |
| Uninitialize(); |
| // If no files were found (e.g., user is typing in rename/search box, or in virtual folders), | ||
| // don't show anything - just return silently to avoid stealing focus | ||
| if (ViewModel.CurrentItem == null) | ||
| { | ||
| Logger.LogInfo("Peek: No files found to preview, showing error."); | ||
| var errorMessage = ResourceLoaderInstance.ResourceLoader.GetString("NoFilesSelected"); | ||
| ViewModel.ShowError(errorMessage); | ||
|
|
||
| // Still show the window so user can see the warning | ||
| this.Show(); | ||
| WindowHelpers.BringToForeground(this.GetWindowHandle()); | ||
| return; | ||
| } |
There was a problem hiding this comment.
This change modifies the user-visible activation behavior when no item is available (e.g., caret-visible typing / no selection / virtual folders). Since Peek has an existing UI test suite (src/modules/peek/Peek.UITests), please add an automated test case that verifies Peek does not open/steal focus when Explorer is in rename mode and Space is pressed, to prevent regressions.
|
@niels9001 |
|
This could be a hotfix |
Don't show error window when CurrentItem is null - just return silently. This restores the original behavior where CaretVisible() detection in GetSelectedItems() would suppress Peek by returning null, and no window would be shown. PR #44703 added an error window for virtual folders (Home/Recent), but this also triggered when user was typing (rename, search, address bar), stealing focus and cancelling the operation. Fixes #44845 <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request
|
Very confused - says it's been merged and closed, but v 0.97.0 |
@the-epoch the fix has been merged, and with a few other fixes, will be available in 0.97.1 which we hope to roll out this week. |
Don't show error window when CurrentItem is null - just return silently. This restores the original behavior where CaretVisible() detection in GetSelectedItems() would suppress Peek by returning null, and no window would be shown. PR #44703 added an error window for virtual folders (Home/Recent), but this also triggered when user was typing (rename, search, address bar), stealing focus and cancelling the operation. Fixes #44845 <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request
|
Fixed on version 0.97.1 - no longer triggered during file rename. |
Don't show error window when CurrentItem is null - just return silently. This restores the original behavior where CaretVisible() detection in GetSelectedItems() would suppress Peek by returning null, and no window would be shown.
PR #44703 added an error window for virtual folders (Home/Recent), but this also triggered when user was typing (rename, search, address bar), stealing focus and cancelling the operation.
Fixes #44845
Summary of the Pull Request