fix(client): fix ime status in variable textarea (#1832)

This commit is contained in:
Junyi 2023-05-10 14:57:59 +07:00 committed by GitHub
parent 8183ff5564
commit fab448c486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -187,7 +187,6 @@ function getCurrentRange(element: HTMLElement): RangeIndexes {
export function TextArea(props) { export function TextArea(props) {
const { value = '', scope, onChange, multiline = true } = props; const { value = '', scope, onChange, multiline = true } = props;
const compile = useCompile(); const compile = useCompile();
const { t } = useTranslation();
const inputRef = useRef<HTMLDivElement>(null); const inputRef = useRef<HTMLDivElement>(null);
const options = compile((typeof scope === 'function' ? scope() : scope) ?? []); const options = compile((typeof scope === 'function' ? scope() : scope) ?? []);
const form = useForm(); const form = useForm();
@ -291,7 +290,7 @@ export function TextArea(props) {
if (ev.key === 'Enter') { if (ev.key === 'Enter') {
ev.preventDefault(); ev.preventDefault();
} }
setIME(ev.keyCode === 229); setIME(ev.keyCode === 229 && ![' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'Enter'].includes(ev.key));
// if (ev.key === 'Control') { // if (ev.key === 'Control') {
// console.debug(getSelection().getRangeAt(0)); // console.debug(getSelection().getRangeAt(0));
// } // }
@ -381,7 +380,7 @@ export function TextArea(props) {
); );
} }
TextArea.ReadPretty = (props) => { TextArea.ReadPretty = function ReadPretty(props): JSX.Element {
const { value, multiline = true, scope } = props; const { value, multiline = true, scope } = props;
const compile = useCompile(); const compile = useCompile();
const options = compile((typeof scope === 'function' ? scope() : scope) ?? []); const options = compile((typeof scope === 'function' ? scope() : scope) ?? []);