mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
fix(mood): make the slider clear affordance an icon, not a text label
The clear-action button sat as muted text beside the value, so a set slider read as one phrase — the number fused with the word next to it (a value of 4 next to "leeren" showed as "4 leeren"). Replace it with an icon-only X that carries the same label as its accessible name, so the value readout stays the bare number in every locale at once.
This commit is contained in:
1 parent
11a6bc40c0
commit
271e6f5db6
2 files changed
+10
-3
No files matched your search
@@ -105,7 +105,11 @@ describe("<SliderField>", () => {
|
||||
it("offers to clear an answer only when there is one to clear", () => {
|
||||
const set = field({ onClear: () => {}, clearLabel: "zurücksetzen" });
|
||||
expect(set).toContain('data-slot="slider-field-clear"');
|
||||
expect(set).toContain("zurücksetzen");
|
||||
// The clear affordance is icon-only: the label rides the accessible name,
|
||||
// not visible text beside the value, so a set slider never reads "4 leeren".
|
||||
expect(set).toContain('aria-label="zurücksetzen"');
|
||||
// The value span holds only the bare number, never the clear-action label.
|
||||
expect(set).toMatch(/data-slot="slider-field-value"[^>]*>7<\/span>/);
|
||||
|
||||
const unanswered = field({
|
||||
value: null,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import * as React from "react";
|
||||
import { Slider as SliderPrimitive } from "radix-ui";
|
||||
import { X } from "lucide-react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
@@ -136,9 +137,11 @@ function SliderField({
|
||||
type="button"
|
||||
onClick={onClear}
|
||||
data-slot="slider-field-clear"
|
||||
className="text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 rounded text-xs underline-offset-2 outline-none hover:underline focus-visible:ring-[3px]"
|
||||
aria-label={clearLabel}
|
||||
className="text-muted-foreground hover:text-foreground focus-visible:ring-ring/50 flex size-6 items-center justify-center rounded outline-none focus-visible:ring-[3px]"
|
||||
>
|
||||
{clearLabel}
|
||||
<X className="size-3.5" aria-hidden="true" />
|
||||
<span className="sr-only">{clearLabel}</span>
|
||||
</button>
|
||||
) : null}
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user