mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-07 23:07:26 +02:00
prevent resetting number inputs with leading 0 while still typing
This commit is contained in:
1 parent
6aa6b2c471
commit
09af56b342
11 files changed
+64
-12
No files matched your search
@@ -35,6 +35,16 @@ export function settings(props) {
|
||||
placeholder: "Default to max ~5MB",
|
||||
value: () => props.field.maxSize || "",
|
||||
oninput: (e) => {
|
||||
// temp skip invalid numbers with leading 0 while typing to avoid reseting the entire input
|
||||
// (always normalized in onchange)
|
||||
if (e.target.value?.length > 1 && e.target.value[0] == "0") {
|
||||
return;
|
||||
}
|
||||
|
||||
props.field.maxSize = parseInt(e.target.value, 10);
|
||||
},
|
||||
onchange: (e) => {
|
||||
props.field.maxSize = null; // reset reactivity
|
||||
props.field.maxSize = parseInt(e.target.value, 10);
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -252,7 +252,19 @@ export function settings(props) {
|
||||
placeholder: "~5MB default",
|
||||
name: () => `fields.${props.fieldIndex}.maxSize`,
|
||||
value: () => props.field.maxSize || "",
|
||||
oninput: (e) => (props.field.maxSize = parseInt(e.target.value, 10)),
|
||||
oninput: (e) => {
|
||||
// temp skip invalid numbers with leading 0 while typing to avoid reseting the entire input
|
||||
// (always normalized in onchange)
|
||||
if (e.target.value?.length > 1 && e.target.value[0] == "0") {
|
||||
return;
|
||||
}
|
||||
|
||||
props.field.maxSize = parseInt(e.target.value, 10);
|
||||
},
|
||||
onchange: (e) => {
|
||||
props.field.maxSize = null; // reset reactivity
|
||||
props.field.maxSize = parseInt(e.target.value, 10);
|
||||
},
|
||||
}),
|
||||
),
|
||||
t.div({ className: "field-help" }, "In bytes."),
|
||||
|
||||
@@ -35,6 +35,16 @@ export function settings(props) {
|
||||
placeholder: "Default to max ~1MB",
|
||||
value: () => props.field.maxSize || "",
|
||||
oninput: (e) => {
|
||||
// temp skip invalid numbers with leading 0 while typing to avoid reseting the entire input
|
||||
// (always normalized in onchange)
|
||||
if (e.target.value?.length > 1 && e.target.value[0] == "0") {
|
||||
return;
|
||||
}
|
||||
|
||||
props.field.maxSize = parseInt(e.target.value, 10);
|
||||
},
|
||||
onchange: (e) => {
|
||||
props.field.maxSize = null; // reset reactivity
|
||||
props.field.maxSize = parseInt(e.target.value, 10);
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -25,7 +25,23 @@ export function input(props) {
|
||||
min: () => props.field.min,
|
||||
max: () => props.field.max,
|
||||
value: () => props.record[props.field.name] || 0,
|
||||
oninput: (e) => props.record[props.field.name] = Number(e.target.value),
|
||||
oninput: (e) => {
|
||||
// temp skip invalid numbers with leading 0 while typing to avoid reseting the entire input
|
||||
// (always normalized in onchange)
|
||||
if (
|
||||
e.target.value?.length > 1
|
||||
&& e.target.value[0] == "0"
|
||||
&& e.target.value[1] != "."
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
props.record[props.field.name] = Number(e.target.value);
|
||||
},
|
||||
onchange: (e) => {
|
||||
props.record[props.field.name] = null; // reset reactivity
|
||||
props.record[props.field.name] = Number(e.target.value);
|
||||
},
|
||||
}),
|
||||
),
|
||||
() => {
|
||||
|
||||
Reference in new issue
Block a user