Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: native context menu runs action under mouse when opened #113175

Open
thwaller opened this issue Dec 20, 2020 · 307 comments
Open

Linux: native context menu runs action under mouse when opened #113175

thwaller opened this issue Dec 20, 2020 · 307 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug electron Issues and items related to Electron linux Issues with VS Code on Linux menus Menu items and widget issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream

Comments

@thwaller
Copy link

Issue Type: Bug

When I right click, the menu will flash on and then off almost immediately, like maybe 100 or 200 milliseconds. This is not all the time, but I am not able to narrow it down. It seems to be only in the editor that this issue exists. I can sometimes "fix" it by right clicking on the left side, like in the Explorer, then going back to the editor. I do not have this issue with any other software on my system. This started maybe Wed this last week, so approx around Dec 16th.

I removed 2 SCSS extensions which I believed were at fault, but with them uninstalled, the problem still exists. Those were my most recently installed extensions, the rest have been there a while.

Regarding what happens, when the right click menu disappears it seems like an option is being selected, almost like there is some sort of double click happening... the first right click to open the menu and a second to select something. I believe this to be the case as different things happen after I right click that normally require me to explicitely call said function.

VS Code version: Code - Insiders 1.53.0-insider (c927a80, 2020-12-18T05:27:50.274Z)
OS version: Linux x64 5.4.0-59-generic

System Info
Item Value
CPUs Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz (8 x 2799)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 0, 0, 0
Memory (System) 31.32GB (0.37GB free)
Process Argv --no-sandbox --unity-launch --crash-reporter-id 99855e03-cc37-4ed5-907b-28a1bf4d8453
Screen Reader no
VM 0%
DESKTOP_SESSION mate
XDG_CURRENT_DESKTOP MATE
XDG_SESSION_DESKTOP mate
XDG_SESSION_TYPE x11
Extensions (68)
Extension Author (truncated) Version
html-snippets abu 0.2.1
scss-lint ada 0.1.10
project-manager ale 12.0.1
code-gnu-global aus 0.2.2
emojisense bie 0.8.0
markdown-checkbox bie 0.1.3
xml2json bui 1.2.4
npm-intellisense chr 1.3.1
path-intellisense chr 2.3.0
vscode-mysql-client2 cwe 2.8.6
vscode-markdownlint Dav 0.38.0
vscode-eslint dba 2.1.14
githistory don 0.6.14
xml Dot 2.5.1
gitlens eam 11.0.6
vscode-html-css ecm 1.2.1
vscode-npm-script eg2 0.3.13
apacheconf-snippets eim 1.3.0
git-project-manager fel 1.7.1
php-intellisense fel 2.3.14
vscode-firefox-debug fir 2.9.1
shell-format fox 7.0.1
vscode-pull-request-github Git 0.22.0
beautify Hoo 1.5.0
vscode-git-add-and-commit iva 2.1.1
search-node-modules jas 1.3.0
shortcut-menu-bar jer 1.5.0
vscode-gnupg-tool JHe 1.3.9
vscode-sshfs Kel 1.19.1
sftp lix 1.12.9
code-beautifier mic 2.3.3
xml-format mik 1.0.2
prettify-json moh 0.0.3
vscode-apache mrm 1.2.0
python ms- 2020.12.424452561
vscode-pylance ms- 2020.12.2
jupyter ms- 2020.12.414227025
cpptools ms- 1.1.3
debugger-for-chrome msj 4.12.11
sqltools mtx 0.23.0
vetur oct 0.31.3
java red 0.73.0
vscode-xml red 0.14.0
shellman Rem 4.7.0
live-sass rit 3.0.0
LiveServer rit 5.6.1
bash-debug rog 0.3.9
joplin-vscode-plugin rxl 0.3.0
bash-beautify sha 0.1.1
markdown-preview-enhanced shd 0.5.13
html5-boilerplate sid 1.1.1
sonarlint-vscode Son 1.19.0
code-spell-checker str 1.10.2
html-preview-vscode tht 0.2.5
shellcheck tim 0.12.2
vscodeintellicode Vis 1.2.10
vscode-java-debug vsc 0.30.0
vscode-java-dependency vsc 0.16.0
vscode-java-pack vsc 0.12.1
vscode-maven vsc 0.27.0
codetour vsl 0.0.42
gistfs vsl 0.1.12
nodejs-extension-pack wad 0.1.9
eno Wsc 2.3.41
JavaScriptSnippets xab 1.8.0
markdown-all-in-one yzh 3.4.0
html-css-class-completion Zig 1.20.0
ab-html-formatter zov 0.0.2
@sbatten
Copy link
Member

sbatten commented Dec 21, 2020

@thwaller what is almost certainly happening is that the menu is being drawn underneath the mouse cursor and that is activating the menu since the mouse up action triggers the item. we can't prevent that mouse up action from triggering as these are native menus, but we can try to fix the position (we already do try but there seems to be a consistent case you are hitting). if you could reproduce and take a short video, that would be helpful.

@sbatten sbatten added the info-needed Issue requires more information from poster label Dec 21, 2020
@thwaller
Copy link
Author

thwaller commented Dec 22, 2020

Please see a right click attempt that worked, then one that did not, then one that did in the video.

Side note: I was disappointed to see that MKV files cannot be uploaded.

EDIT: Before anyone comments, I have no issue with showing the credentials, they are only temp during this process.

screen.mp4

@thwaller
Copy link
Author

Interesting. For me, I have tried what you suggest and attached a video of a series of right clicks at different lengths of time pressing the button down. For me, it did not seem to make a difference, it just changed how fast the menu disappeared. Also note that in this video you can see the mouse cursor is not moving, it is just a series of right clicks.

screen.mp4

@sbatten sbatten added bug Issue identified by VS Code Team member as probable bug linux Issues with VS Code on Linux menus Menu items and widget issues and removed info-needed Issue requires more information from poster labels Jan 4, 2021
@sbatten
Copy link
Member

sbatten commented Jan 4, 2021

@deepak1556 if you get a chance, maybe you could help me with this some time. It seems even with the same coordinates on our side, the menu is sometimes still drawn under the cursor on linux and I am not sure we can do any more about it.

@yume-chan
Copy link
Contributor

yume-chan commented Feb 7, 2021

@sbatten How about always using custom menus, but still allow title bar style to be switched between native and custom?

@bogdanbeniaminb
Copy link

bogdanbeniaminb commented Feb 7, 2021

Yes, using custom menus does help, but it creates other issues for my workflow. One is that I can no longer hide the title bar, as I currently do with the native one (I'm using Linux/KDE). The other is that the menus are much, much larger, to a point where using them means scrolling through the list of options and this makes the workflow more difficult.

I understand some have had this issue years ago as well (I found a github issue opened 4 years ago), but for me personally it only appeared in VSCode 1.53. I reverted back to 1.52 and it's working fine again. It seems to be something related either to the Electron version used in 1.53 or to VSCode itself.

For me personally, using the "custom menus" workaround doesn't seem a solution. I would rather prefer this issue is investigated and fixed, as you would normally do with bugs.

Thank you.

@thwaller
Copy link
Author

thwaller commented Feb 7, 2021

I understand some have had this issue years ago as well (I found a github issue opened 4 years ago), but for me personally it only appeared in VSCode 1.53. I reverted back to 1.52 and it's working fine again. It seems to be something related either to the Electron version used in 1.53 or to VSCode itself.

I agree with this statement. This issue is "new" for me as well. There was a change somewhere that caused this issue, at least for some of us.

@IvanSafonov
Copy link

I have the same issue with VS Code 1.53. And it also works normal in 1.52.

Version: 1.53.0
Commit: 8490d3dde47c57ba65ec40dd192d014fd2113496
Date: 2021-02-03T15:56:04.185Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 5.4.0-65-generic

@jayschwa
Copy link

For me, this problem happens when I right-click in a central area of my window. If I right-click near an edge, the menu does not spawn under the pointer hot spot.

@hofingermarkus
Copy link

I have the same problem on VSCode 1.53.2 on Ubuntu 18.04 64bit

My Quickfix solution to use VSCode even thouhg it has the bug, is to not right-click but to right-hold.
Then the context menu shows up and stays as long as one holds the right button pressed
As soon as you release the right mouse button, the lift event seems to click the currently selected line on the context menu - even though the event comes from the right mouse button.

Maybe it could be possible to implement a locking mechanism.
I.e. when the mouse up action triggers the context menu, the callback code checks that the according mouse button is truly different from the one that triggered the context menu.
In this way the same click should not be able to trigger it.

@acim
Copy link

acim commented Feb 23, 2021

Same here, Linux Mint 20.1, Firefox 85.0.1, VSCodium 1.53.2. And yes, it started not that long ago, maybe a month or two. Same happens in Parallels on Mac, then same versions of Mint, Firefox and VSCodium.

@deepak1556
Copy link
Collaborator

I am trying to repro the issue,

  • Ubuntu 20.04 with x11
  • CentOS 8 with x11

Couldn't see the issue with both native and custom context menus. Can anyone provide exact repro steps along with a sample workspace, also please provide the value of XDG_SESSION_TYPE.

@acim
Copy link

acim commented Feb 23, 2021

I am trying to repro the issue,

* Ubuntu 20.04 with x11

* CentOS 8 with x11

Couldn't see the issue with both native and custom context menus. Can anyone provide exact repro steps along with a sample workspace, also please provide the value of XDG_SESSION_TYPE.

Do you have some extension that add stuff to the context menu? Like GitLens, Go...

@deepak1556
Copy link
Collaborator

Do you have some extension that add stuff to the context menu? Like GitLens, Go...

No, the test was done without any extensions.

I have installed gitlens now and still doesn't repro the issue. Can you start with code --user-data-dir /tmp/code-test which will setup the app with fresh configuration and if you can repro the issue here, please provide the steps.

Side note, can you check if the issue repros with code --disable-gpu ?

@acim
Copy link

acim commented Feb 23, 2021

Do you have some extension that add stuff to the context menu? Like GitLens, Go...

No, the test was done without any extensions.

I have installed gitlens now and still doesn't repro the issue. Can you start with code --user-data-dir /tmp/code-test which will setup the app with fresh configuration and if you can repro the issue here, please provide the steps.

Side note, can you check if the issue repros with code --disable-gpu ?

I tried this and it seems to work fine. I suspect to zoom level now. When I just start code without flags (old setup) and set zoom level back to zero, it behaves better but I will need more time to prove this.

@bogdanbeniaminb
Copy link

Do you have some extension that add stuff to the context menu? Like GitLens, Go...

No, the test was done without any extensions.

I have installed gitlens now and still doesn't repro the issue. Can you start with code --user-data-dir /tmp/code-test which will setup the app with fresh configuration and if you can repro the issue here, please provide the steps.

Side note, can you check if the issue repros with code --disable-gpu ?

You need some extensions to add items to your context menus. The issue only appears when the context menu appears under the mouse cursor - you need enough items in the context menu or a screen that is short enough (in height) so that the context menu can't go up or down, avoiding the mouse cursor.

@justinleebehnke
Copy link

I am so grateful for all of you reporting on this issue and also for those who are working on this issue and repo.

I am on Ubuntu 20.04.1 LTS x86_64
VSCode version 1.53.2

BEFORE (sorry I don't know which release it started happening but it was within the last 2 weeks)

What used to happen when I right-click is the menu would appear and then I can left-click to select what I am looking for.

AFTER

Now what I need to do is right-click and HOLD while I move my cursor off of the pop-up window menu, THEN release right-click, and then I can left-click on the thing that I want to choose.

Another option is to hold the right-click down until I have my cursor pointing over the thing that I want to select and then release right-click and it will select that item

What I believe is happening is the release of the right-click when a menu is opened is being interpreted as a selection.

I believe that before it was opening the menu on "mouse up" from right-click and NOW it is opening the menu on "mouse-down" of right-click and therefore entering selection mode and interpreting "mouse up" as a selection.

That's just what I am perceiving and I hope it is helpful. (I find it very unnatural to move my cursor while holding right-click on my laptop)

@acim
Copy link

acim commented Feb 24, 2021

After I disabled zoom, it works fine on my laptop (two fingers touch).

@lephuongbg
Copy link

I think this issue is due to VS Code does not work well with high DPI settings. I set my font DPI to 120 so that things are not super tiny on my screen and this issue consistently happens. If I set my font DPI to default then the problem goes away. One would have thought that since Chromium doesn't have this issue, VS Code shouldn't also have it.

image

@JSKenyon
Copy link

After I disabled zoom, it works fine on my laptop (two fingers touch).

This seems to have worked for me too.

@jarrocha
Copy link

jarrocha commented Aug 1, 2023

@bpasero Just wanted to add that I was not able to reproduce the problem on native menu on different zooms. I tried on custom menu and only on high zoom the menu shows underneath the cursor, but it doesn't auto selects an option like it used to. So on my view this is fixed. I tested with insiders version 1.81.0 on Ubuntu 20.04 and GNOME 3.36.8.

Thank you for the effort. The temporary fixed supplied by another user works but it would revert on rebooting the system so this fixed is greatly appreciated.

If this fix is accepted, how long until we see it on an official release?

@bpasero
Copy link
Member

bpasero commented Aug 1, 2023

Great to hear, so it seems to have improved the situation at least for some users. We plan to release a new version this Thursday.

@Igetin
Copy link

Igetin commented Aug 4, 2023

The bug no longer exists for me on 1.81.0 stable!

@Igetin
Copy link

Igetin commented Aug 4, 2023

☝ …scratch that above. It still happens. :(

For me, it seems that it is more likely to happen when the context menu is drawn on the left side of the cursor (i.e. when the right-click is performed closer to the right edge of the screen/window. I was able to reproduce it on both sides, though.

I have now switched to using "window.titleBarStyle": "custom", since the problem does not happen with it on version 1.81.0.

@bpasero
Copy link
Member

bpasero commented Aug 4, 2023

@Igetin did you also set window.experimental.nativeContextMenuLocation: true in settings?

@scaomath
Copy link

scaomath commented Aug 4, 2023

Setting "window.experimental.nativeContextMenuLocation": true, in the setting json finally solved this problem for me after so many years (I bought two 32 inch monitors to solve this problem back in 2022).

@bogdanbeniaminb
Copy link

For me, it still happens with version 1.81.0, but only as @Igetin said, when the menu opens to the left of the mouse cursor (which happens quite often on my laptop monitor). It seems that setting "window.experimental.nativeContextMenuLocation": true doesn't do any difference in my case.

@bpasero
Copy link
Member

bpasero commented Aug 5, 2023

but only as said, when the menu opens to the left of the mouse cursor

In that case, does the menu also need to have enough entries to scroll or in other words open to the top and bottom of the mouse location or is that independent?

@bogdanbeniaminb
Copy link

but only as said, when the menu opens to the left of the mouse cursor

In that case, does the menu also need to have enough entries to scroll or in other words open to the top and bottom of the mouse location or is that independent?

It only happens when the menu has enough entries to open to the top and bottom of the mouse cursor location. If there are less entries and the menu opens only to the bottom, it doesn't happen.

@Igetin
Copy link

Igetin commented Aug 5, 2023

@Igetin did you also set window.experimental.nativeContextMenuLocation: true in settings?

I have now enabled that setting and tried right-clicking in a bunch of spots. It seems that it now occurs less often, but it still does occur. Unfortunately, that’s not enough for me. I need it to never ever do that. So, for now, if there’s even a small chance of it happening, I cannot use the native context menu and will use the custom one instead.

Like @bogdanbeniaminb said, I think it seems to happen when there are a lot of entries in the context menu. For example, in the Git diff view, when right-clicking the right pane.

@thwaller
Copy link
Author

I had a chance to check the status of this. I am using VSCode version 1.82.0-insider. The issue appears to be resolved, with no editing of settings required. I have only tested this on a few files, one for sure I know I had open when I reported the issue. My test is by no means comprehensive, but considering this issue happened prior on every right click for me, not seeing it happen at all on multiple files shows a clear change.

@flipflop133
Copy link

flipflop133 commented Sep 29, 2023

I had a chance to check the status of this. I am using VSCode version 1.82.0-insider. The issue appears to be resolved, with no editing of settings required. I have only tested this on a few files, one for sure I know I had open when I reported the issue. My test is by no means comprehensive, but considering this issue happened prior on every right click for me, not seeing it happen at all on multiple files shows a clear change.

I'm using 1.82.2 on arch linux and the bug is still happening, I'm using a custom DPI set in .Xressources of 144 (1.5x) and bigger fonts set in gtk-${3,4}.0/settings.ini which increase context menus sizes and started to trigger this issue for me.
PS: "window.experimental.nativeContextMenuLocation": true doesn't change anything for me.
PS2: some people said that the issue only happen when the menu appears on the left, for me the issue appear on both sides.
PS3: using "window.titleBarStyle": "custom" fixes the issue for, and the UI is so much nicer!

@itoffshore
Copy link

itoffshore commented Sep 29, 2023

@flipflop133 - switching menus from native to custom under Arch improved things for me (I also set zoom to 1.5 instead of altering the DPI on XFCE desktop) - which is left at default settings)

EDIT: 14th Nov - have been running VScode with these settings for 6 weeks now with no right click menu issues

@flipflop133
Copy link

flipflop133 commented Sep 29, 2023

@itoffshore yeah, thanks I stated in my previous comment in PS3 that it fixed the issue for me, but the issue is not specific to VS Code, it also happened with browser menus (haven't encountered the issue for a while though).

@103sbavert
Copy link

For some reason @itoffshore's workaroound has stopped working for me.

@itoffshore
Copy link

itoffshore commented Jul 24, 2024

@103sbavert - still working ok for me on Arch Linux / XFCE 4.18.6 with visual-studio-code-bin-1.91

# $HOME/.config/Code/User/settings.json
{
    "telemetry.telemetryLevel": "off",
    "customizeUI.stylesheet": {

    },
    "terminal.integrated.fontSize": 13,
    "security.workspace.trust.untrustedFiles": "open",
    "files.autoSave": "afterDelay",
    "workbench.editor.enablePreview": false,
    "files.trimTrailingWhitespace": true,
    "window.zoomLevel": 1.5,
    "window.titleBarStyle": "custom",
    "terminal.integrated.scrollback": 10000,
    "workbench.settings.applyToAllProfiles": [
        "terminal.integrated.scrollback"
    ]
}

@103sbavert
Copy link

103sbavert commented Jul 24, 2024

Might be relevant but I am sing VSCodium, altho it happens on the AUR visual-studio-code-bin package as well.

here's my settings.json:

{
    "files.autoSave": "afterDelay",
    "window.titleBarStyle": "custom",
    "files.autoSaveDelay": 1000,
    "editor.fontSize": 13,
    "editor.fontFamily": "'JetBrains Mono NL'",
    "editor.wordWrapColumn": 150,
    "window.restoreWindows": "none",
    "terminal.integrated.cursorStyle": "line",
    "terminal.integrated.cursorBlinking": true,
    "terminal.integrated.fontSize": 13,
    "terminal.integrated.tabs.location": "left",
    "terminal.integrated.enablePersistentSessions": false,
    "terminal.integrated.persistentSessionReviveProcess": "never",
    "security.workspace.trust.untrustedFiles": "open",
    "diffEditor.codeLens": true,
	"editor.codeLensFontFamily": "'JetBrains Mono NL'",
	"window.customTitleBarVisibility": "auto",
    "editor.insertSpaces": false,
	"editor.detectIndentation": false,
	"terminal.external.linuxExec": "kgx",
	"terminal.explorerKind": "both",
	"window.zoomLevel": 0,
}

@adriandelgg
Copy link

Issue is still present today. It's been happening for years.

@philopatrick
Copy link

https://stackoverflow.com/questions/66419930/the-popup-menu-coming-on-right-click-disappears-instantly-in-vscode

this stackoverflow method work for me, my system is ubuntu 22.04, hope help

@adriandelgg
Copy link

https://stackoverflow.com/questions/66419930/the-popup-menu-coming-on-right-click-disappears-instantly-in-vscode

this stackoverflow method work for me, my system is ubuntu 22.04, hope help

Which comment exactly was it that fixed the issue?

@philopatrick
Copy link

philopatrick commented Sep 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug electron Issues and items related to Electron linux Issues with VS Code on Linux menus Menu items and widget issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.