8282-testToMaster #1057

Merged
alexm merged 215 commits from 8282-testToMaster into master 2024-12-10 06:23:36 +00:00
1 changed files with 7 additions and 7 deletions
Showing only changes of commit 2fa8c3f88a - Show all commits

View File

@ -88,6 +88,7 @@ const mixinRules = [
const handleKeydown = (e) => {
if (e.key === 'Backspace') return;
if ($props.insertable && e.key.match(/[0-9]/)) {
handleInsertMode(e);
}
@ -97,20 +98,19 @@ const handleInsertMode = (e) => {
e.preventDefault();
const input = e.target;
const cursorPos = input.selectionStart;
const { maxlength } = vnInputRef.value;
let currentValue = value.value;
if (!currentValue) currentValue = e.key;
const newValue = Number(e.key);
if (newValue && !isNaN(newValue)) {
const newValue = e.key;
if (newValue && !isNaN(newValue) && cursorPos < maxlength) {
value.value =
currentValue.substring(0, cursorPos) +
newValue +
currentValue.substring(cursorPos + 1);
nextTick(() => {
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
});
}
nextTick(() => {
input.setSelectionRange(cursorPos + 1, cursorPos + 1);
});
};
</script>