CE-1402 Only do flushSync and setSelectionRange after a toUpper/Lower and add a try-catch, just in case (specifically, because failed on input type=number)

This commit is contained in:
2024-06-25 07:58:12 -05:00
parent 28bc07cce4
commit 3ec43fbbd3

View File

@ -191,30 +191,33 @@ export const makeTextField = (field: QFieldMetaData, criteria: QFilterCriteriaWi
const beforeStart = event.target.selectionStart;
const beforeEnd = event.target.selectionEnd;
flushSync(() =>
let isToUpperCase = DynamicFormUtils.isToUpperCase(field);
let isToLowerCase = DynamicFormUtils.isToLowerCase(field);
if (isToUpperCase || isToLowerCase)
{
let newValue = event.currentTarget.value;
let isToUpperCase = DynamicFormUtils.isToUpperCase(field);
let isToLowerCase = DynamicFormUtils.isToLowerCase(field);
if (isToUpperCase)
flushSync(() =>
{
newValue = newValue.toUpperCase();
}
if (isToLowerCase)
let newValue = event.currentTarget.value;
if (isToUpperCase)
{
newValue = newValue.toUpperCase();
}
if (isToLowerCase)
{
newValue = newValue.toLowerCase();
}
event.currentTarget.value = newValue;
});
const input = document.getElementById(inputId);
if (input)
{
newValue = newValue.toLowerCase();
// @ts-ignore
input.setSelectionRange(beforeStart, beforeEnd);
}
event.currentTarget.value = newValue;
});
const input = document.getElementById(inputId);
if (input)
{
// @ts-ignore
input.setSelectionRange(beforeStart, beforeEnd);
}
valueChangeHandler(event, valueIndex);