Skip to content

Commit 2e75779

Browse files
crux153gaearon
authored andcommitted
Fix incorrect data in compositionend event with Korean IME on IE11 (#10217) (#12563)
* Add isUsingKoreanIME function to check if a composition event was triggered by Korean IME * Add Korean IME check alongside useFallbackCompositionData and disable fallback mode with Korean IME
1 parent bc963f3 commit 2e75779

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/react-dom/src/events/BeforeInputEventPlugin.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ function getDataFromCustomEvent(nativeEvent) {
200200
return null;
201201
}
202202

203+
/**
204+
* Check if a composition event was triggered by Korean IME.
205+
* Our fallback mode does not work well with IE's Korean IME,
206+
* so just use native composition events when Korean IME is used.
207+
* Although CompositionEvent.locale property is deprecated,
208+
* it is available in IE, where our fallback mode is enabled.
209+
*
210+
* @param {object} nativeEvent
211+
* @return {boolean}
212+
*/
213+
function isUsingKoreanIME(nativeEvent) {
214+
return nativeEvent.locale === 'ko';
215+
}
216+
203217
// Track the current IME composition status, if any.
204218
let isComposing = false;
205219

@@ -229,7 +243,7 @@ function extractCompositionEvent(
229243
return null;
230244
}
231245

232-
if (useFallbackCompositionData) {
246+
if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) {
233247
// The current composition is stored statically and must not be
234248
// overwritten while composition continues.
235249
if (!isComposing && eventType === eventTypes.compositionStart) {
@@ -378,7 +392,9 @@ function getFallbackBeforeInputChars(topLevelType: TopLevelType, nativeEvent) {
378392
}
379393
return null;
380394
case TOP_COMPOSITION_END:
381-
return useFallbackCompositionData ? null : nativeEvent.data;
395+
return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)
396+
? null
397+
: nativeEvent.data;
382398
default:
383399
return null;
384400
}

0 commit comments

Comments
 (0)