Monaco-editor: Right click opening command palette window

Created on 17 Nov 2018  路  7Comments  路  Source: microsoft/monaco-editor

Steps or JS usage snippet reproducing the issue:
go here.
Playground

just right click on "module Conway {" on the editor. command palette opens up.

bug important

Most helpful comment

There were 3 issues:

  • The layout code wasn't respecting window.pageYOffset. That's what I meant @sbatten, when the page is scrolled down, we need to shift that math by that amount of pixels.
  • The menu was still being drawn right under the cursor, I shifted it by 2px to the side.
  • Focusing the menu was happening before it was laid out, so there was situations in which it would force the browser to scroll up just to reveal the focused element. Fixed that by having distinct render & focus steps.

All 7 comments

@sbatten this is the same issue we ran into yesterday, let's fix this on Monday.

I can reproduce. I think there are two issues hidden here.

  1. The positioning is broken. No matter how much space there is below that location on the page, the context menu always wants to be rendered to the top:
    image

  2. There must be some form of double interpreting of the mouse event, where the first right click to show the context menu leads to the last entry being selected.

(I could grab the screenshot by using Shift+F10 to show the context menu instead of right clicking)

@alexandrudima, 2 is expected, this behavior is to enable the right click hold, drag, select functionality. We've run into this issue multiple times on Linux because of placement (1 above) and @joaomoreno has fixed it a few times. I'll take a look today

Placement seems to be wrong because the page actually scrolls.

@sbatten @joaomoreno I would appreciate a fix for this when you get a chance, I'm waiting for this to make a new editor recovery release. Thanks!

@joaomoreno looked into this and have ideas/concerns though I know you own this code and have made several changes to address this issue.

  • The anchor being used in the context view is 1px by 2px but it doesn't appear to be used as a radius, which means there isn't a guarantee of separation between the mouse and menu
  • I can get the menu to appear both below and above the mouse click though it seems to prefer above. Could you clarify what you meant about page scrolling?
  • Range intersect detection seems to count ends as exclusive and this might need to be taken into consideration?

There were 3 issues:

  • The layout code wasn't respecting window.pageYOffset. That's what I meant @sbatten, when the page is scrolled down, we need to shift that math by that amount of pixels.
  • The menu was still being drawn right under the cursor, I shifted it by 2px to the side.
  • Focusing the menu was happening before it was laid out, so there was situations in which it would force the browser to scroll up just to reveal the focused element. Fixed that by having distinct render & focus steps.
Was this page helpful?
0 / 5 - 0 ratings