This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try disabling 'blockSelectEvents' flag
Summary: In the past Draft.js set a 'blockSelectEvents' flag on 'componentWillUpdate' and unset it in 'componentDidUpdate'. The reason for this, according to comments in the code, was that IE will fire a 'selectionChange' event when we programmatically change the selection, meaning it would trigger a new select event while we are in the middle of updating. **Edit:** We found that the 'selection.addRange' was what triggered the stray `selectionchange` event in IE, for the record.[1] Thanks sophiebits for the tip about that. When manually testing, I saw no bugs or inconsistencies introduced when the extra 'selectionchange' event fired in IE. The event would go into React, and yet it was never logged as triggering a handler in Draft.js. So either that `selectionchange` event was not one that Draft.js. listened to, or React ignores/defers it because it's in the middle of a commit. This diff does two things: - Add logging to verify if we ever actually use the `blockSelectEvents` flag in practice. Is it actually blocking anything??? And if not, as I suspect, then; - We can just remove it. This also removes it under a GK, so we can test on 50% employees first and see if they experience any bugs. Lastly - I do want to add tests for this. It is error-prone and time consuming to set up and repeately do manual testing. Going to put together an outline of what I think the test should look like in a follow-up diff. --- [1]: Here are the logs I recorded, for posterity ``` // inside of DraftEditor#focus calling forceSelection calling udpate with new editor state and new selection componentWillUpdate fired! This is where blockSelectEvents would be set to true~~~ a leaf is about to call setDraftEditorSelection removing all ranges from the selection calling range.setStart **calling selection.addRange** **React got an event of type topSelectionChange** **window got an event of 'selectionchange'** componentDidUpdate fired This is where blockSelectEvents would be set to false~~~ React got an event of type topBlur React got an event of type topFocus Draft got an event of onFocus Draft returned early because currentSelection already matches the updated selection ``` Reviewed By: sophiebits Differential Revision: D6866079 fbshipit-source-id: 01034c6404df892224f5c18a45cba744a64d6e38
- Loading branch information