microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.63k stars 29.04k forks source link

When opening and closing the context menu, focus position is sometimes lost. #117756

Closed MarcoZehe closed 10 months ago

MarcoZehe commented 3 years ago

Issue Type: Bug

  1. Open a folder as a workspace.
  2. Press CMD+Shift+E or CTRL+Shift+E to focus on explorer and choose a file.
  3. Press your context menu key.
  4. Arrow through the menu, then decide you don't want to select an item, and press Escape.

Result: In some cases, focus position is lost, and keyboard focus is not on the file you were on before.

This worked in 1.53.

Will attach a screeencast.

VS Code version: Code - Insiders 1.54.0-insider (3290f9a73ba6fc3b1063ea32476067434ee91b1d, 2021-02-26T05:25:57.426Z) OS version: Darwin arm64 20.4.0

System Info |Item|Value| |---|---| |CPUs|undefined| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|2, 2, 2| |Memory (System)|16.00GB (0.18GB free)| |Process Argv|--crash-reporter-id 4ea43554-4a6d-4f7c-b2fb-6de1a3610d98| |Screen Reader|yes| |VM|0%|
Extensions (37) Extension|Author (truncated)|Version ---|---|--- npm-intellisense|chr|1.3.1 gitignore|cod|0.6.0 doxdocgen|csc|1.1.0 dart-code|Dar|3.19.2 flutter|Dar|3.19.0 vscode-markdownlint|Dav|0.39.0 vscode-eslint|dba|2.1.14 gitlens|eam|11.2.1 EditorConfig|Edi|0.16.4 vscode-npm-script|eg2|0.3.16 prettier-vscode|esb|5.9.2 vscode-pull-request-github|Git|0.23.1 beautify|Hoo|1.5.0 better-cpp-syntax|jef|1.15.5 jstl|jsx|1.0.4 flutter-intl|loc|1.13.0 vscode-docker|ms-|1.10.0 vscode-edge-devtools|ms-|1.1.3 python|ms-|2021.2.582707922 vscode-pylance|ms-|2021.2.4 jupyter|ms-|2021.3.593162453 remote-containers|ms-|0.161.0 remote-ssh|ms-|0.64.0 remote-ssh-edit|ms-|0.64.0 remote-wsl|ms-|0.54.0 cmake-tools|ms-|1.6.0 cpptools|ms-|1.2.2 cpptools-extension-pack|ms-|1.0.0 vscode-github-issue-notebooks|ms-|0.0.68 vscode-markdown-notebook|ms-|0.0.14 vsliveshare|ms-|1.0.3784 vsliveshare-audio|ms-|0.1.91 debugger-for-edge|msj|1.0.15 indent-report|ogo|1.0.0 nunjucks|ron|0.3.0 cmake|twx|0.0.17 vscode-webhint|web|1.5.11 (1 theme extensions excluded)
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368:30146709 vsreu685:30147344 python383:30185418 pythonvspyt602:30263608 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstry244:30244315 pythonvsdeb440:30224570 pythonvsded773:30223139 pythonvspyt875:30259475 pythontb:30258533 vscoresta800cf:30263255 vsc_aa:30263845 ```
gjsjohnmurray commented 3 years ago

Does this also happen after you use the command to reload with all extensions temporarily disabled?

MarcoZehe commented 3 years ago

screen cast showing the issue.

MarcoZehe commented 3 years ago

Does this also happen after you use the command to reload with all extensions temporarily disabled?

Yes.

isidorn commented 3 years ago

@MarcoZehe thanks! Yeah I see the same, so the focus seems to go back to the Tree, but the focused element remains. So if you press down the right element will get focused. @joaomoreno did you change something here by purpose? When we dismiss the context menu can we move the focus back to the item where it was triggered?

joaomoreno commented 3 years ago

@isidorn You see the same on a mac?

I don't see this using custom menus.

isidorn commented 3 years ago

Yeah, I see it when using VoiceOver, steps:

  1. Turn on Voice Over
  2. Navigate to some item in explorer
  3. Press ctrl + option + shift + M -> context menu triggered
  4. Press ESC -> notice tree is focused, not the item in the tree
joaomoreno commented 3 years ago

Can you reproduce with Shift F10?

joaomoreno commented 3 years ago

OK the problem is still only with ctrl + option + shift + M and voiceover. My fix from yesterday isn't perfect... This feature is really tricky.

joaomoreno commented 3 years ago

OK now I can't reproduce any more. And then I can. And then I can't.

This Ctrl Option Shift M feature is very flaky.

MarcoZehe commented 3 years ago

My screencast shows that as well. It seems to matter whether you walk down the menu using the arrow keys, possibly even wrap around to the top, before pressing Escape.

joaomoreno commented 3 years ago

Thanks @MarcoZehe, will definitely investigate further and try to get a fix out for February.

joaomoreno commented 3 years ago

@deepak1556: @isidorn and I were able to repro this occasionally. It's definitely hard to repro, but when it happens here's what's going on: the user presses Escape to close the context menu but Escape is still forwarded as a keyboard event to the DOM, effectively clearing the tree's focus. So the Escape key event gets handled twice. Any thoughts?

Btw we can't repro this when the context menu is opened via mouse, only via keyboard with the Ctrl Shift Meta M shortcut, having VoiceOver enabled.

@deepak1556 I added you since it seems like an Electron/macOS issue?

deepak1556 commented 10 months ago

@MarcoZehe can you check if this is still an issue with latest insiders https://code.visualstudio.com/insiders ?

vscodenpa commented 10 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!