This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[bug] Incorrect behavior of getRangeClientRects in webkit browsers #570
Comments
@qrohlf We have this problem as well. Here is my monkey patch. import { getVisibleSelectionRect as draftVSR } from 'draft-js';
function getVisibleSelectionRect(window) {
let selection = draftVSR(window);
// When selection the first word of the wrapped line, chrome will return two rects
// And the first rect has 0 width
if (selection) {
const selectionRects = window.getSelection().getRangeAt(0).getClientRects();
if (selectionRects.length === 2 && selectionRects[0].width === 0) {
selection = selectionRects[1];
}
}
return selection;
} |
vierno
added a commit
to vierno/draft-js
that referenced
this issue
Dec 16, 2016
pofigizm
pushed a commit
to pofigizm/draft-js
that referenced
this issue
Jan 26, 2017
erykpiast
pushed a commit
to prezly-forks/draft-js
that referenced
this issue
Mar 17, 2017
ouchxp
pushed a commit
to ouchxp/draft-js
that referenced
this issue
Apr 7, 2017
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
video demo: https://www.youtube.com/watch?v=TpNzVH5jlcU
live demo: http://codepen.io/qrohlf/pen/YWjzOq?editors=1010#0
getVisibleSelectionRect does not fully work around webkit's bad behavior regarding selection range bounding boxes. Selecting the first word on a wrapped line results in an incorrect bounding box. Bug exists in Chrome 51.0.2704.106 and Safari 9.1.1 (11601.6.17).
You can see the bad behavior this causes in the inline toolbar in Facebook Notes:
normal behavior
![screen shot 2016-07-28 at 4 19 37 pm](https://cloud.githubusercontent.com/assets/347189/17232759/388e2c00-54df-11e6-80f8-bcc05dfe609f.png)
oh look, it's the webkit contenteditable selection range bounding box bug (WCESRBBB)
![screen shot 2016-07-28 at 4 19 44 pm](https://cloud.githubusercontent.com/assets/347189/17232773/4f038f70-54df-11e6-8833-d09960eeedcc.png)
Hopefully once I finish the other functionality in the project I'm using draft for, I can circle back around and fix this bug, but if someone else wants to fix it for me I won't argue :).
The text was updated successfully, but these errors were encountered: