-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Remove selectionStart polyfill? #11806
Comments
Tagging as good first issue—the outcome is a report on which browsers support the feature. |
I am fairly sure it's ie8 only for inputs/text areas. We just removed the equivalent code in a bunch of libraries with no (observable) issues so far. I'd imagine tho the story is different contenteditable? Maybe the draftjs folks have some insight? |
Tagging @flarnie |
(I haven’t thought about CE but you might be right!) |
I also checked at caniuse. Seems support starts from IE9. |
MDN also reports IE9 and up support. |
The comment |
This example shows that unlike other inputs or a textarea, 'selectionStart' is not available on a contenteditable div. So let's keep this polyfill, and also add a test for this somewhere. I would love to have a Draft.js fixture, but maybe just a contenteditable fixture or test. |
For anyone interested in more info: In Draft we rely on the similar but different Selection interface - |
@flarnie Would this test suffice? Mainly checking selection start is working where we expect and showing that it doesn't work in the ce case? That way when it's supported we are aware and can remove the backwards support? Or did you have something else in mind? |
@xxblakefailxx Glad to see a test for this - I should have been more clear that I recommend keeping this polyfill in place, and so the test would verify that it does work for contenteditable. If we reverse the expectation of the last test in the suite you wrote then it looks good to me. To remove this polyfill would be a breaking change, because that would remove our support for selection in It looks like Draft relies entirely on the Selection api, which is different, but I imagine that adding this support was based in part on potential use cases with Draft.js. @sophiebits can confirm whether removing this polyfill would also break Draft.js. |
I know contenteditable inputs don't work properly without this. Maybe there is something we can do in user space (such as in draft itself) but it can't just be removed. |
@flarnie @sophiebits Do you know of a way we can manual test that shows the contenteditables not working without the polyfill? |
Not sure but I think if you comment out this code and try to use any Draft editor then you will probably see the problem. If it's not obvious when typing directly then try cutting/pasting and more complex cursor movements. |
Is someone working on this issue? If not then I would love to work on this issue :) |
Discussing in the comments we determined that |
The issue may be specific to Draft. If someone wants to investigate and determine exactly what the problem is, maybe we can remove this code from React. |
It's an issue with any If we really want to remove it, to avoid a 'gotcha' for users we would want a dev-only warning when they use |
Yes, selectionStart does not exist, but we only need it in order to restore selection, which we may not need for Draft. If we moved that logic into Draft then we could skip the selection restoration logic for contenteditable. We already have a warning against contenteditable saying it's unsupported. |
Looking at this code:
react/packages/react-dom/src/client/ReactInputSelection.js
Lines 91 to 100 in bee4baf
When would
selectionStart
not exist? According to http://help.dottoro.com/ljtfkhio.php, only in IE8. (It might be wrong though.)It would be nice to check, and remove the relevant code if it's supported everywhere else.
The text was updated successfully, but these errors were encountered: