try to see if this fixes safari back
on of the 2 changes (updating dom async from compositionend, or ignoring keydown while composing) here has, while fixing chrome, broken safari. Don't do the async dom updating for safari if that was it.pull/21833/head
parent
7bda1c58eb
commit
ffe34ee8a1
|
@ -169,15 +169,31 @@ export default class BasicMessageEditor extends React.Component {
|
||||||
|
|
||||||
_onCompositionEnd = (event) => {
|
_onCompositionEnd = (event) => {
|
||||||
this._isIMEComposing = false;
|
this._isIMEComposing = false;
|
||||||
// some browsers (chromium) don't fire an input event after ending a composition
|
// some browsers (Chrome) don't fire an input event after ending a composition,
|
||||||
// so trigger a model update after the composition is done by calling the input handler.
|
// so trigger a model update after the composition is done by calling the input handler.
|
||||||
// do this async though, as modifying the DOM from the compositionend event might confuse the composition.
|
|
||||||
setTimeout(() => {
|
// however, modifying the DOM (caused by the editor model update) from the compositionend handler seems
|
||||||
|
// to confuse the IME in Chrome, likely causing https://github.com/vector-im/riot-web/issues/10913 ,
|
||||||
|
// so we do it async
|
||||||
|
|
||||||
|
// however, doing this async seems to break things in Safari for some reason, so browser sniff.
|
||||||
|
|
||||||
|
const ua = navigator.userAgent.toLowerCase();
|
||||||
|
const isSafari = ua.includes('safari/') && !ua.includes('chrome/');
|
||||||
|
|
||||||
|
if (isSafari) {
|
||||||
this._onInput({inputType: "insertCompositionText"}, true);
|
this._onInput({inputType: "insertCompositionText"}, true);
|
||||||
}, 0);
|
} else {
|
||||||
|
setTimeout(() => {
|
||||||
|
this._onInput({inputType: "insertCompositionText"}, true);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isComposing(event) {
|
isComposing(event) {
|
||||||
|
// checking the event.isComposing flag just in case any browser out there
|
||||||
|
// emits events related to the composition after compositionend
|
||||||
|
// has been fired
|
||||||
return !!(this._isIMEComposing || event.isComposing);
|
return !!(this._isIMEComposing || event.isComposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ export default class EditMessageComposer extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
_onKeyDown = (event) => {
|
_onKeyDown = (event) => {
|
||||||
|
// ignore any keypress while doing IME compositions
|
||||||
if (this._editorRef.isComposing(event)) {
|
if (this._editorRef.isComposing(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ export default class SendMessageComposer extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
_onKeyDown = (event) => {
|
_onKeyDown = (event) => {
|
||||||
|
// ignore any keypress while doing IME compositions
|
||||||
if (this._editorRef.isComposing(event)) {
|
if (this._editorRef.isComposing(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue