fix(web): validation of number input fields (#9789)

This commit is contained in:
Michel Heusschen
2024-05-27 10:19:08 +02:00
committed by GitHub
parent e3d39837d0
commit 298370b7be
3 changed files with 27 additions and 4 deletions

View File

@@ -9,6 +9,7 @@
<script lang="ts">
import { quintOut } from 'svelte/easing';
import type { FormEventHandler } from 'svelte/elements';
import { fly } from 'svelte/transition';
import PasswordField from '../password-field.svelte';
@@ -25,7 +26,9 @@
export let isEdited = false;
export let passwordAutocomplete: string = 'current-password';
const validateInput = () => {
const handleChange: FormEventHandler<HTMLInputElement> = (e) => {
value = e.currentTarget.value;
if (inputType === SettingInputFieldType.NUMBER) {
let newValue = Number(value) || 0;
if (newValue < min) {
@@ -77,8 +80,7 @@
{step}
{required}
{value}
on:input={(e) => (value = e.currentTarget.value)}
on:blur={validateInput}
on:change={handleChange}
{disabled}
{title}
/>