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
DOM Selections cleared when <select>ing outside editor #2123
Comments
I think the best move here is to make this configurable. I can't promise I'll look into this right away since I'm quite busy at the moment (work and personal todos piling up 😅), but I'd be happy to either review a PR or look into this in a couple of weeks. |
I'm also fine with the proposal as long as we preserve the current behavior as default. This could also have significant accessibility impact so this change would have to be verified to be friendly to screen readers. |
facebook-github-bot
pushed a commit
that referenced
this issue
Jul 16, 2019
Summary: **Summary** This adds a `preserveSelectionOnBlur` prop as per #2123 **Test Plan** Tests were added for the two possible scenarios. I'm not sure how much to mock in this test because it is just testing a specific branch of code, so I've faked certain details like the rangeCount. What do you think mrkev claudiopro ? Pull Request resolved: #2128 Reviewed By: claudiopro Differential Revision: D16270879 Pulled By: mrkev fbshipit-source-id: 304af92c1211b8ff95741bff434b4fe3c4b6dd7d
jdecked
pushed a commit
to twitter-forks/draft-js
that referenced
this issue
Oct 9, 2019
Summary: **Summary** This adds a `preserveSelectionOnBlur` prop as per facebookarchive#2123 **Test Plan** Tests were added for the two possible scenarios. I'm not sure how much to mock in this test because it is just testing a specific branch of code, so I've faked certain details like the rangeCount. What do you think mrkev claudiopro ? Pull Request resolved: facebookarchive#2128 Reviewed By: claudiopro Differential Revision: D16270879 Pulled By: mrkev fbshipit-source-id: 304af92c1211b8ff95741bff434b4fe3c4b6dd7d
mmissey
pushed a commit
to mmissey/draft-js
that referenced
this issue
Mar 24, 2020
Summary: **Summary** This adds a `preserveSelectionOnBlur` prop as per facebookarchive#2123 **Test Plan** Tests were added for the two possible scenarios. I'm not sure how much to mock in this test because it is just testing a specific branch of code, so I've faked certain details like the rangeCount. What do you think mrkev claudiopro ? Pull Request resolved: facebookarchive#2128 Reviewed By: claudiopro Differential Revision: D16270879 Pulled By: mrkev fbshipit-source-id: 304af92c1211b8ff95741bff434b4fe3c4b6dd7d
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Do you want to request a feature or report a bug?
Feature.
I'm happy to open a PR with this change however I first wanted to see if there was interest in this from the Draft team.
What is the current behavior?
DOM Selections are cleared on blur.
What is the expected behavior?
DOM Selections are maintained.
I hoped to find a config option to disable this behaviour but there was no none.
Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?
All versions.
In the Draft source there's this function and code comment,
In our web app we have a toolbar outside the
<Editor>
for formatting, and this toolbar has both<button>
s and<select>
s.The
<select>
s are the problem in Draft.js because clicking them visibly deselects any text. Have a look at https://jsfiddle.net/y4Lszjv5/ and type some text, select it (while making sure that the selection would be visible with the native<select>
expanded) and the selection will disappear while the<select>
is expanded. This makes it harder to see which text would be formatted.Note that Quill and most other editors don't have this problem as they leave the consistent browser behaviour as-is (as your code comment notes "This is consistent across all browsers").
So I guess there are two potential solutions,
_selection.removeAllRanges();
, or<select>
specifically and don't run_selection.removeAllRanges();
when focus has moved to that type of element.The text was updated successfully, but these errors were encountered: