fix(ui): correctly initialize InputNumber

When the value is outside min/max the value should not be clamped.
This commit is contained in:
2026-02-06 15:25:18 +01:00
parent cf8943b205
commit 6acce72fb8
2 changed files with 15 additions and 2 deletions

View File

@@ -19,7 +19,6 @@
// normalize bounds // normalize bounds
if (min > max) [min, max] = [max, min]; if (min > max) [min, max] = [max, min];
if (value > max) max = value;
let inputEl: HTMLInputElement | undefined = $state(); let inputEl: HTMLInputElement | undefined = $state();
@@ -105,7 +104,7 @@
} }
onMount(() => { onMount(() => {
value = snap(clamp(value)); value = snap(value);
}); });
</script> </script>

View File

@@ -42,4 +42,18 @@ describe('InputNumber', () => {
await expect.element(input).toHaveAttribute('min', '0'); await expect.element(input).toHaveAttribute('min', '0');
await expect.element(input).toHaveAttribute('max', '10'); await expect.element(input).toHaveAttribute('max', '10');
}); });
it('should not clamp value on init when value exceeds min/max', async () => {
render(InputNumber, { value: 100, min: 0, max: 10 });
const input = page.getByRole('spinbutton');
await expect.element(input).toHaveValue(100);
});
it('should not clamp value on init when value is below min', async () => {
render(InputNumber, { value: -50, min: 0, max: 10 });
const input = page.getByRole('spinbutton');
await expect.element(input).toHaveValue(-50);
});
}); });