-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Bug] Mouse click incorrectly sets the caret position #3217
Comments
Can you provide an example in the playground to reproduce your issue? Thanks! |
Hi @hediet ! Thanks for the quick reply. I managed to get something that has similar issues with minimum code. My case is not as drastic, so in the example the caret won't move from the beginning, in my actual code it does move but to a wrong position. You can notice that if you click and type, the internal position does get moved though. I am using StencilJS for my custom elements with shadow DOM, so it might work better in my code due to stencil adding polyfills and other stuff. |
I'm sorry, but we need an example in our playground to properly investigate this bug and to rule out that, for example, StencilJS polyfills cause this issue. |
If you paste the code I added above in the description into the javascript tab in the playground it will reproduce |
There are some references to problems with the caret in this other issue: |
@janarvaez Did you find a fix or workaround? I'm facing the same issue and using monaco inside a shadowDOM is a requirement for me |
I have 2 workarounds.
|
The workaround 1 worked but I figured it out my actual problem. I had one external style from an ancestor component(outside the shadowDOM) that was setting I suppose that somehow it is not considering styles coming from outside the shadowDOM during the font measurements, or something like that. In my case removing this style was not a problem, so I sticked with that solution. |
Hello @hediet ! |
Screen.Recording.2023-03-16.at.09.25.15.movPlease look at this reproduction video |
I also stumbled into this. It worked fine in Microsoft Edge versions prior to |
I can reproduce the bug in edge, but not chrome. @sorinui can you look into this? |
🤔 I'm using Chrome 111.0.5563.64 on mac and the bug is there |
@lucasMarioza thanks for sharing this! Enabling/disabling this rule actually changes if This really looks like a bug in chrome to me. As a workaround, you can disable the font-feature-settings in the editor options. |
Has someone already raised a chrome issue? |
I created a chrome issue (cause after switch to 111 it also happens on my computer): https://bugs.chromium.org/p/chromium/issues/detail?id=1426792 |
I suggest you create a minimal reproducible example for them (not using monaco editor), demonstrating the issue that |
is this surely the cause of the issue? |
duplicate: #3858 |
We analysed how this issue behaves in Chrome, Firefox, and Safari, looks like for Firefox Monaco editor is not accessing the |
@hediet |
The change in https://github.com/microsoft/vscode/pull/178795/files is not setting |
I am experiencing this issue in my PayloadCMS instance which uses this package for their Code field. I'm running Chrome on MacOS. Is this the same issue or slightly different? Screen.Recording.2023-06-02.at.1.58.12.PM.mov |
Situation as @TheDunco |
I don't see this issue on Version 114.0.5735.199 (Official Build) (64-bit) on Windows (playground example), thus I assume this got fixed in Chrome.
This is true, but there does not seem to be a way to consider this setting when measuring the text with |
Re Chrome changes: We have at least not reverted or modified the |
@drott thanks for letting us know! Once someone can reproduce with the latest chrome/monaco editor or vscode and can share reproducible steps, we'll reopen. Off topic, but thanks so much for bringing back the "restart frame" feature in v8/Chrome! I use it daily and it just saves so much time! |
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Code
Reproduction Steps
No response
Actual (Problematic) Behavior
I created a MonacoEditor which has issues with highlighting text and setting the caret in the desired position when clicking with the mouse, and I can't figure out what's going on.
I added a few console logs as an example, and for instance, I get:
What could be interfering with the correct position of the caret in the editor? How could it be that a click further to the right return a lower column number?
The deviation is not consistent or proportional either. If I click in the same place, I do get it in the same position. But clicking in one place can have +2 columns wrong, in another to the right have about +6 columns wrong, and further to the right the caret can be even positioned -7 columns in the other direction (like in the example above).
Expected Behavior
Clicking in the editor correctly positions the caret
Additional Context
No response
UPDATE: I found out the issue is when using the editor inside a shadowDOM
Edit by @hediet: Check here for verification steps
The text was updated successfully, but these errors were encountered: