作成日: 2020/03/09 最終更新日: 2020/04/15
文書種別
不具合
発生環境
Chromeのみで発生
状況
修正済み
詳細
下記のように、テキストコントロールの書式に空白文字と全角文字を指定した状態で、再現手順のとおり文字を入力していくと、途中で入力した空白文字が削除されます。
format: 'SZ'
再現手順
format: 'SZ'
再現手順
- 「あいうえお」と入力する
- 「あいう えお」のように空白文字(スペース)を入力する
- 「あいう えおかきく」のように後ろに続けて文字を入力して確定する
回避方法
この問題は、InputManJS V2.3Jで修正されました。
修正版を適用しない場合の回避方法は次の通りです。
下記コードのように、ブラウザがGoogle Chromeかつスペースが入力された場合にcompositionイベントを手動で発生させます。
◎サンプルコード
修正版を適用しない場合の回避方法は次の通りです。
下記コードのように、ブラウザがGoogle Chromeかつスペースが入力された場合にcompositionイベントを手動で発生させます。
◎サンプルコード
gcTextBox.getUIInputElement().addEventListener('compositionupdate', function (e) {
if (e.isTrusted) {
gcTextBox._isIMEInputing = true;
}
});
gcTextBox.getUIInputElement().addEventListener('compositionend', function (e) {
gcTextBox._isIMEInputing = false;
});
gcTextBox.onKeyDown(function (sender, args) {
var evt = args.Event;
/** chromeの場合のみ実行する */
if (!/Chrome/.test(navigator.userAgent) || !/Google Inc/.test(navigator.vendor)) {
return;
}
/** スペースの場合のみ実行する */
if (evt.keyCode !== 229 || evt.code !== "Space") {
return;
}
/** ユーザーが入力中は実行しない*/
if (sender._isIMEInputing) {
return;
}
/** compositionイベントを発生させる */
setTimeout(function () {
var input = sender.getUIInputElement();
raiseCompositionEvent(input, "compositionstart");
raiseCompositionEvent(input, "compositionupdate");
raiseCompositionEvent(input, "compositionend");
}, 100);
args.Cancel = true;
});
function raiseCompositionEvent(input, name) {
var event = new Event("CompositionEvent");
event.initEvent(name, true, true);
input.dispatchEvent(event);
}
if (e.isTrusted) {
gcTextBox._isIMEInputing = true;
}
});
gcTextBox.getUIInputElement().addEventListener('compositionend', function (e) {
gcTextBox._isIMEInputing = false;
});
gcTextBox.onKeyDown(function (sender, args) {
var evt = args.Event;
/** chromeの場合のみ実行する */
if (!/Chrome/.test(navigator.userAgent) || !/Google Inc/.test(navigator.vendor)) {
return;
}
/** スペースの場合のみ実行する */
if (evt.keyCode !== 229 || evt.code !== "Space") {
return;
}
/** ユーザーが入力中は実行しない*/
if (sender._isIMEInputing) {
return;
}
/** compositionイベントを発生させる */
setTimeout(function () {
var input = sender.getUIInputElement();
raiseCompositionEvent(input, "compositionstart");
raiseCompositionEvent(input, "compositionupdate");
raiseCompositionEvent(input, "compositionend");
}, 100);
args.Cancel = true;
});
function raiseCompositionEvent(input, name) {
var event = new Event("CompositionEvent");
event.initEvent(name, true, true);
input.dispatchEvent(event);
}
旧文書番号
84988