Skip to content

Commit

Permalink
Fix DOMObserver mutation data for IE (#2285)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebookarchive/draft-js#2285

IE 11 considers the enter keypress that concludes the composition as an input char, which ends up adding a new line to the editor. I am adding code to strip that newline character when processing the mutation event.

Reviewed By: mrkev

Differential Revision: D19141003

fbshipit-source-id: 53848e42d0e2b45d609e6623cc5d5579168b73fe
  • Loading branch information
Jainil Parekh authored and facebook-github-bot committed Dec 18, 2019
1 parent 04b41ca commit 68b82a3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/component/handlers/composition/DOMObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ class DOMObserver {
// These events are also followed by a `childList`, which is the one
// we are able to retrieve the offsetKey and apply the '' text.
if (target.textContent !== '') {
// IE 11 considers the enter keypress that concludes the composition
// as an input char. This strips that newline character so the draft
// state does not receive spurious newlines.
if (USE_CHAR_DATA) {
return target.textContent.replace('\n', '');
}
return target.textContent;
}
} else if (type === 'childList') {
Expand Down

0 comments on commit 68b82a3

Please sign in to comment.