From 3227033237d774602c7219a994a191b1aeec0e6c Mon Sep 17 00:00:00 2001 From: william garrity Date: Fri, 30 Jan 2026 21:42:27 -0500 Subject: [PATCH 1/5] fix(BusinessHoursEditor): add default args for boolean controls - Add meta.args with defaults for disabled, showDescription, use24Hour, weekStartsOn, addHoursLabel - Remove hardcoded showDescription from wrapper - Clean up redundant args in individual stories --- .../BusinessHoursEditor.stories.tsx | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx index ecf717af..56aa16ed 100644 --- a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx +++ b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx @@ -44,6 +44,13 @@ const meta: Meta = { description: 'Label for add hours button', }, }, + args: { + disabled: false, + showDescription: true, + use24Hour: false, + weekStartsOn: 0, + addHoursLabel: 'Add Hours', + }, }; export default meta; @@ -59,12 +66,7 @@ function BusinessHoursEditorWrapper( return (
- +

Current Schedule:

@@ -78,18 +80,12 @@ function BusinessHoursEditorWrapper( export const Default: Story = { render: (args) => , - args: { - showDescription: true, - weekStartsOn: 0, - addHoursLabel: 'Add Hours', - }, }; export const Empty: Story = { render: (args) => , args: { value: [], - showDescription: true, }, }; @@ -97,7 +93,6 @@ export const WeekdaysOnly: Story = { render: (args) => , args: { value: createWeekdaySchedule('08:00', '18:00'), - showDescription: true, }, }; @@ -114,7 +109,6 @@ export const MondayStart: Story = { args: { value: createDefaultSchedule(), weekStartsOn: 1, - showDescription: true, }, }; From faaeb2d495dbf026cd9c50309e63619990881b25 Mon Sep 17 00:00:00 2001 From: william garrity Date: Fri, 30 Jan 2026 21:58:09 -0500 Subject: [PATCH 2/5] fix(BusinessHoursEditor): fix Storybook controls and hide non-functional props - Hide 'value', 'onChange', 'className' controls from Storybook docs - Clicking 'Set object' on value control caused 'schedule.find is not a function' error because Storybook defaults to {} (object) instead of [] (array) - These props are managed by the interactive wrapper component - Hide 'use24Hour' control - prop exists in interface but is not implemented - Component uses native which uses browser locale - Prop is destructured as _use24Hour (intentionally unused) - Can be implemented in future if 24-hour format support is needed - Add default args for remaining controls (disabled, showDescription, weekStartsOn, addHoursLabel) - Ensures boolean controls start with actual values instead of undefined - Add useEffect to sync schedule state when props.value changes from Storybook controls --- .../BusinessHoursEditor.stories.tsx | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx index 56aa16ed..02fa5a71 100644 --- a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx +++ b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { BusinessHoursEditor, DaySchedule, @@ -22,6 +22,13 @@ const meta: Meta = { }, }, argTypes: { + // Hide props that are managed by the demo wrapper + value: { table: { disable: true } }, + onChange: { table: { disable: true } }, + className: { table: { disable: true } }, + // use24Hour is not implemented in the component (native time inputs use browser locale) + use24Hour: { table: { disable: true } }, + disabled: { control: 'boolean', description: 'Whether the editor is disabled', @@ -30,10 +37,6 @@ const meta: Meta = { control: 'boolean', description: 'Whether to show description field for each time slot', }, - use24Hour: { - control: 'boolean', - description: 'Use 24-hour format', - }, weekStartsOn: { control: 'radio', options: [0, 1], @@ -47,7 +50,6 @@ const meta: Meta = { args: { disabled: false, showDescription: true, - use24Hour: false, weekStartsOn: 0, addHoursLabel: 'Add Hours', }, @@ -64,6 +66,13 @@ function BusinessHoursEditorWrapper( props.value || createDefaultSchedule() ); + // Sync schedule state when props.value changes (e.g., from Storybook controls) + useEffect(() => { + if (props.value !== undefined) { + setSchedule(props.value); + } + }, [props.value]); + return (
From 2c7093104b55c664a5eec718bb26289ad5239b83 Mon Sep 17 00:00:00 2001 From: william garrity Date: Fri, 30 Jan 2026 22:07:59 -0500 Subject: [PATCH 3/5] fix: destructure value/onChange to prevent props override Address Copilot review feedback: spread props was overriding controlled state. Now destructure value and onChange from props before spreading restProps, ensuring the wrapper's controlled state is always used. --- .../BusinessHoursEditor.stories.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx index 02fa5a71..9b269a30 100644 --- a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx +++ b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx @@ -62,20 +62,23 @@ type Story = StoryObj; function BusinessHoursEditorWrapper( props: Partial> ) { + // Destructure value and onChange to prevent them from overriding controlled state + const { value: initialValue, onChange: _onChange, ...restProps } = props; + const [schedule, setSchedule] = useState( - props.value || createDefaultSchedule() + initialValue || createDefaultSchedule() ); - // Sync schedule state when props.value changes (e.g., from Storybook controls) + // Sync schedule state when initialValue changes (e.g., from Storybook controls) useEffect(() => { - if (props.value !== undefined) { - setSchedule(props.value); + if (initialValue !== undefined) { + setSchedule(initialValue); } - }, [props.value]); + }, [initialValue]); return (
- +

Current Schedule:

From 38231248816f504e69e785fddd8c54568ad37d39 Mon Sep 17 00:00:00 2001 From: william garrity Date: Fri, 30 Jan 2026 22:13:34 -0500 Subject: [PATCH 4/5] fix: use underscore to satisfy no-unused-vars lint rule --- .../BusinessHoursEditor.stories.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx index 9b269a30..d3580615 100644 --- a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx +++ b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx @@ -59,11 +59,11 @@ export default meta; type Story = StoryObj; // Interactive wrapper -function BusinessHoursEditorWrapper( - props: Partial> -) { - // Destructure value and onChange to prevent them from overriding controlled state - const { value: initialValue, onChange: _onChange, ...restProps } = props; +function BusinessHoursEditorWrapper({ + value: initialValue, + onChange: _, + ...restProps +}: Partial>) { const [schedule, setSchedule] = useState( initialValue || createDefaultSchedule() From 81cf7501717ae2b27e16e99270ec1f961ef3a420 Mon Sep 17 00:00:00 2001 From: william garrity Date: Fri, 30 Jan 2026 22:18:57 -0500 Subject: [PATCH 5/5] style: apply Prettier formatting --- .../BusinessHoursEditor/BusinessHoursEditor.stories.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx index d3580615..cfffb420 100644 --- a/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx +++ b/src/components/BusinessHoursEditor/BusinessHoursEditor.stories.tsx @@ -64,7 +64,6 @@ function BusinessHoursEditorWrapper({ onChange: _, ...restProps }: Partial>) { - const [schedule, setSchedule] = useState( initialValue || createDefaultSchedule() ); @@ -78,7 +77,11 @@ function BusinessHoursEditorWrapper({ return (
- +

Current Schedule: