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

Cursor invisible after drag-n-drop in Firefox #583

Open
0b10011 opened this issue Mar 10, 2017 · 13 comments
Open

Cursor invisible after drag-n-drop in Firefox #583

0b10011 opened this issue Mar 10, 2017 · 13 comments

Comments

@0b10011
Copy link

0b10011 commented Mar 10, 2017

  1. Load http://prosemirror.net/
  2. Drag logo into the ProseMirror editor example
  3. Click somewhere in the editor
  4. Type "foo"

Expected: Cursor should appear after step 3, and "foo" should be inserted

Actual: Cursor never appears, but "foo" is still inserted at the proper location

Appears to be a bug with Firefox's contenteditable implementation (there are several on bugzilla regarding the cursor). I haven't dug into it too much yet, but clicking elsewhere (eg, the "A toolkit..." title) and then clicking back into the editor will show the cursor again.

@marijnh
Copy link
Member

marijnh commented Mar 10, 2017

There's not a whole lot we can do about browsers being terrible, especially when its effect isn't actually observable in JavaScript. If you want to help, investigating whether other contentEditable-based editors are affected and seeing if they have a working workaround would be a good approach.

@0b10011
Copy link
Author

0b10011 commented Mar 10, 2017

Yeah, I meant to mention I was going to look into this later. (There's a good chance I'll be opening several issues over the next week or so... I'm going to try to follow up on them myself if you aren't able to get to them.)

The workaround mentioned in the linked stackoverflow thread mentions focusing a generated <a> and then setting the focus back to the [contenteditable] element. I'll try playing around with this next week sometime. (I'll also be opening a bug on bugzilla if I can't find an existing one for the exact issue.)

@adrianheine
Copy link
Member

I have a similar issue in Firefox I think due to having stored marks and thus a cursor wrapper.

@marijnh
Copy link
Member

marijnh commented Oct 18, 2017

Can this be reproduced in a demo? Does force-resetting the DOM selection after drop help?

adrianheine added a commit to ProseMirror/website that referenced this issue Oct 18, 2017
@adrianheine
Copy link
Member

@0b10011 gave steps for prosemirror.net, but I cannot reproduce the issue with those steps in my FF56. As for my incarnation of the issue: It is reproducible with a rather simple modification to the basic demo. You need to have a background-color and a stored mark. It's probably what this person on Stackoverflow ran into.

@marijnh
Copy link
Member

marijnh commented Oct 18, 2017

Okay, so then drag-and-drop isn't actually involved. Opening a new issue #712

@frederik
Copy link

Here is a glitch that reproduces the issue after a drag.

(mostly unmodified Dinosaur demo).

As indicated, these seem to be separate issues. This one might be related to https://bugzilla.mozilla.org/show_bug.cgi?id=800050 though I did not get the workaround mentioned in the last post to work.

@afwn90cj93201nixr2e1re
Copy link

afwn90cj93201nixr2e1re commented Jul 24, 2019

https://sticky-ferret.glitch.me
Lil typo fixes.

@jljorgenson18
Copy link

You can resolve this by having a hidden input somewhere and then after you are done handling the drop event, you move the native selection into that hidden input and then move it back to inside of PM. It forces a sort of soft reset where Firefox will fix itself. You can use a selection bookmark to restore the selection and you will need to all restore storedMarks and then call view.focus. If you do that though, the cursor should come back.

We use this "cursor parking" technique in a few spots to get around weird native issues where the browser breaks something on prevented events or the browser ignores your prevent defaults (like the touchbar with Safari).

@jljorgenson18
Copy link

Just to note, you do need a set timeout between moving the focus and restoring the selection.

@jljorgenson18
Copy link

@marijnh
Copy link
Member

marijnh commented Mar 18, 2020

Does this still happen for anyone with current Firefox versions?

@aduchate
Copy link

aduchate commented Jan 4, 2021

I still have a similar problem on Firefox 84, when I use web components. When I have 2 prosemirror instances on the same page, each in their own shadow dom. If I try to switch from one PM to the other without clicking first on the background of the window, the carret is not displayed, though the focus is set correctly and typing works as expected.

Update: I created a separate issue : #1113 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants