Skip to content

Commit 976c3d2

Browse files
ellatrixyouknowriad
authored andcommitted
RichText: run input rule on composition end (#17610)
1 parent 07013c7 commit 976c3d2

File tree

1 file changed

+10
-2
lines changed
  • packages/rich-text/src/component

1 file changed

+10
-2
lines changed

packages/rich-text/src/component/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,11 @@ class RichText extends Component {
326326
// (CJK), do not trigger a change if characters are being composed.
327327
// Browsers setting `isComposing` to `true` will usually emit a final
328328
// `input` event when the characters are composed.
329-
if ( event && event.nativeEvent.isComposing ) {
329+
if (
330+
event &&
331+
event.nativeEvent &&
332+
event.nativeEvent.isComposing
333+
) {
330334
// Also don't update any selection.
331335
document.removeEventListener( 'selectionchange', this.onSelectionChange );
332336
return;
@@ -335,6 +339,10 @@ class RichText extends Component {
335339
let inputType;
336340

337341
if ( event ) {
342+
inputType = event.inputType;
343+
}
344+
345+
if ( ! inputType ) {
338346
inputType = event.nativeEvent.inputType;
339347
}
340348

@@ -401,7 +409,7 @@ class RichText extends Component {
401409
onCompositionEnd() {
402410
// Ensure the value is up-to-date for browsers that don't emit a final
403411
// input event after composition.
404-
this.onInput();
412+
this.onInput( { inputType: 'insertText' } );
405413
// Tracking selection changes can be resumed.
406414
document.addEventListener( 'selectionchange', this.onSelectionChange );
407415
}

0 commit comments

Comments
 (0)