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

(Firefox) Misplaced caret when selecting a RichText element #11812

Closed
mcsf opened this issue Nov 13, 2018 · 11 comments · Fixed by #13697
Closed

(Firefox) Misplaced caret when selecting a RichText element #11812

mcsf opened this issue Nov 13, 2018 · 11 comments · Fixed by #13697
Labels
Browser Issues Issues or PRs that are related to browser specific problems [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended
Milestone

Comments

@mcsf
Copy link
Contributor

mcsf commented Nov 13, 2018

Describe the bug

Caret is erroneously positioned at the start of a RichText element when selecting a block in Firefox.

To Reproduce

Steps to reproduce the behavior:

  1. Start with a post (I'm using a sizable post provided here).
  2. Make sure no blocks are selected.
  3. Click on the end of a textful RichText element, or click in the middle of the text.
  4. Observed: Caret is positioned at the start of the element.

Expected behavior

Caret should be placed where I clicked.

Screenshots

richtext-caret-firefox

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Firefox Developer Edition
@mcsf mcsf added [Type] Bug An existing feature does not function as intended [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable Browser Issues Issues or PRs that are related to browser specific problems [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... labels Nov 13, 2018
@mcsf mcsf added this to the 4.4 milestone Nov 13, 2018
@youknowriad youknowriad modified the milestones: 4.4, 4.5 Nov 15, 2018
@oandregal
Copy link
Member

oandregal commented Nov 15, 2018

I can repro this in Ubuntu Linux, Firefox 63.

It looks like this happens only the first time a block is selected. If I repeat the steps outlined by @mcsf the caret ends up in the proper position the second and subsequent times.

@oandregal
Copy link
Member

oandregal commented Nov 15, 2018

In my testing, step 2 above (making sure no block is selected) isn't necessary, I can always repro this bug the first time a block is selected.

@oandregal
Copy link
Member

This is what I know so far. When this bug is reproduced:

  • createRecord returns 0 as the start and end positions.
  • window.getSelection() returns 0 as its anchorOfftset and focusOffset. Accordingly, getAnchorAt( 0 ) returns also 0 for startOffset and endOffset.

The offset values for selection/range are properly set when the behavior is correct.

Checked MDN and canisue for compatibility issues but didn't find any.

@mcsf
Copy link
Contributor Author

mcsf commented Nov 16, 2018

@nosolosw, thanks for testing. I haven't checked, but did #11965 help at all?

@oandregal
Copy link
Member

No, it hasn't solved this.

@oandregal
Copy link
Member

oandregal commented Nov 16, 2018

I'm struggling to find a minimal reproducible case to report to bugzilla.

Searching in the database I've found this one: getSelection() returns wrong anchorNode/anchorOffset when selection contains nested different contenteditable context. It points to this jsfiddle to play with the testcase. Sharing in case it sparks any thoughts.

@ellatrix
Copy link
Member

I can look into this issue, but it seems slightly less pressing atm?

@mcsf
Copy link
Contributor Author

mcsf commented Nov 19, 2018

I'm sure other issues are more pressing, but this one is nevertheless a pretty bad experience.

@mcsf mcsf modified the milestones: 4.5, 4.6, WordPress 5.0.x Follow Ups Nov 19, 2018
@mcsf
Copy link
Contributor Author

mcsf commented Nov 19, 2018

Since this is a browser issue and we need to really focus on our priorities, punting to Follow-Ups.

@danielbachhuber
Copy link
Member

I've run into this issue too on the latest master. Here's a GIF of my experience:

clicktarget

@mcsf
Copy link
Contributor Author

mcsf commented Feb 8, 2019

Just for the record, I can still repro this, but I've also noticed that the caret only gets misplaced (at the beginning of the element) if that RichText element has never been focused before. Once a RichText element A has been focused, then placing the caret in some other field/block, then placing it back on A will result in the caret being properly placed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Browser Issues Issues or PRs that are related to browser specific problems [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants