Skip to content

Commit afb708f

Browse files
Jainil Parekhfacebook-github-bot
authored andcommitted
Fix DOMObserver mutation data for IE (facebookarchive#2285)
Summary: Pull Request resolved: facebookarchive#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
1 parent efcaf42 commit afb708f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/component/handlers/composition/DOMObserver.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ class DOMObserver {
110110
// These events are also followed by a `childList`, which is the one
111111
// we are able to retrieve the offsetKey and apply the '' text.
112112
if (target.textContent !== '') {
113+
// IE 11 considers the enter keypress that concludes the composition
114+
// as an input char. This strips that newline character so the draft
115+
// state does not receive spurious newlines.
116+
if (USE_CHAR_DATA) {
117+
return target.textContent.replace('\n', '');
118+
}
113119
return target.textContent;
114120
}
115121
} else if (type === 'childList') {

0 commit comments

Comments
 (0)