monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

Right click opening command palette window

Open yln99517 opened this issue 8 years ago • 7 comments

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

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

yln99517 avatar Nov 17 '18 16:11 yln99517

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

rebornix avatar Nov 17 '18 18:11 rebornix

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)

alexdima avatar Nov 19 '18 08:11 alexdima

@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

sbatten avatar Nov 19 '18 17:11 sbatten

Placement seems to be wrong because the page actually scrolls.

joaomoreno avatar Nov 20 '18 09:11 joaomoreno

@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!

alexdima avatar Nov 20 '18 15:11 alexdima

@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?

sbatten avatar Nov 21 '18 02:11 sbatten

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.

joaomoreno avatar Nov 21 '18 15:11 joaomoreno