From d660279c97f687bb6c7468e844672d04c609b1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 1 Jun 2026 19:37:58 +0200 Subject: [PATCH] fix(medications): stop the wizard showing each time-of-day suggestion twice The schedule wizard's time-of-day step rendered the four suggested times twice: once as the icon chips from the step itself, and again as the labelled preset row built into the chip component below. Add an opt-out on the chip component and pass it from the step so only the icon-based suggestions remain. The period is still conveyed by the icon plus an aria-label; the offered times and selection logic are unchanged. The preset row stays on by default for every other caller. --- .../scheduling/TimesOfDayChips.tsx | 76 +++++++++++-------- .../__tests__/TimesOfDayChips.test.tsx | 18 +++++ .../medications/wizard/steps/Step7Times.tsx | 4 + 3 files changed, 65 insertions(+), 33 deletions(-) diff --git a/src/components/medications/scheduling/TimesOfDayChips.tsx b/src/components/medications/scheduling/TimesOfDayChips.tsx index 3b01e87b3..b166b6293 100644 --- a/src/components/medications/scheduling/TimesOfDayChips.tsx +++ b/src/components/medications/scheduling/TimesOfDayChips.tsx @@ -46,6 +46,13 @@ export interface TimesOfDayChipsProps { disabled?: boolean; /** Translation namespace prefix. */ i18nPrefix?: string; + /** + * Render the built-in Morning / Noon / Evening / Night preset row. + * Default `true`. The wizard's Step 7 supplies its own icon-based + * preset row, so it passes `false` to avoid showing each suggested + * time twice (the icon chip from Step 7 and the labelled chip here). + */ + showPresets?: boolean; } /** Preset table — wall-clock HH:mm and i18n suffix key. */ @@ -106,6 +113,7 @@ export function TimesOfDayChips({ maxChips = 8, disabled = false, i18nPrefix = "medications.scheduling.timesOfDay", + showPresets = true, }: TimesOfDayChipsProps) { const { t } = useTranslations(); const inputId = useId(); @@ -165,38 +173,40 @@ export function TimesOfDayChips({ aria-label={t(`${i18nPrefix}.label`)} > {/* Preset row */} -
- {PRESETS.map(({ key, value: preset }) => { - const isOn = sortedValue.includes(preset); - const label = `${t(`${i18nPrefix}.presets.${key}`)} ${preset}`; - return ( - - ); - })} -
+ {showPresets && ( +
+ {PRESETS.map(({ key, value: preset }) => { + const isOn = sortedValue.includes(preset); + const label = `${t(`${i18nPrefix}.presets.${key}`)} ${preset}`; + return ( + + ); + })} +
+ )} {/* Chip list */} {sortedValue.length === 0 ? ( @@ -225,7 +235,7 @@ export function TimesOfDayChips({ disabled={disabled} aria-label={`${t(`${i18nPrefix}.remove`)} ${time}`} onClick={() => onRemove(time)} - className="focus-visible:ring-ring inline-flex h-7 w-7 items-center justify-center rounded-sm hover:bg-background focus-visible:outline-none focus-visible:ring-2 disabled:opacity-50" + className="focus-visible:ring-ring hover:bg-background inline-flex h-7 w-7 items-center justify-center rounded-sm focus-visible:ring-2 focus-visible:outline-none disabled:opacity-50" data-slot="times-of-day-chip-remove" >