From e2b8446fa3c94a14e820425de213eddf460e10f3 Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Tue, 28 Jan 2025 09:55:17 -0800 Subject: [PATCH] Remove confusing componentManagesLoading control in async story --- .../SelectPanel.features.stories.tsx | 28 ++++--------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/packages/react/src/SelectPanel/SelectPanel.features.stories.tsx b/packages/react/src/SelectPanel/SelectPanel.features.stories.tsx index ef0addab688..868db174e60 100644 --- a/packages/react/src/SelectPanel/SelectPanel.features.stories.tsx +++ b/packages/react/src/SelectPanel/SelectPanel.features.stories.tsx @@ -3,7 +3,7 @@ import type {Meta, StoryObj} from '@storybook/react' import Box from '../Box' import {Button} from '../Button' import type {ItemInput, GroupedListProps} from '../deprecated/ActionList/List' -import {SelectPanel} from './SelectPanel' +import {SelectPanel, type SelectPanelProps} from './SelectPanel' import { FilterIcon, GearIcon, @@ -17,12 +17,10 @@ import { import useSafeTimeout from '../hooks/useSafeTimeout' import FormControl from '../FormControl' -type SelectPanelPropsAndCustomArgs = React.ComponentProps & {componentManagesLoading?: boolean} - const meta = { title: 'Components/SelectPanel/Features', component: SelectPanel, -} satisfies Meta +} satisfies Meta export default meta @@ -489,9 +487,8 @@ export const WithLabelInternally = () => { ) } -export const AsyncFetch: StoryObj = { - render: ({initialLoadingType, height, componentManagesLoading}: SelectPanelPropsAndCustomArgs) => { - const [loading, setLoading] = React.useState(true) +export const AsyncFetch: StoryObj = { + render: ({initialLoadingType, height}: SelectPanelProps) => { const [selected, setSelected] = React.useState([]) const [filteredItems, setFilteredItems] = React.useState([]) const [open, setOpen] = useState(false) @@ -499,29 +496,20 @@ export const AsyncFetch: StoryObj = { const {safeSetTimeout, safeClearTimeout} = useSafeTimeout() const fetchItems = (query: string) => { - setLoading(true) - if (filterTimerId.current) { safeClearTimeout(filterTimerId.current) } filterTimerId.current = safeSetTimeout(() => { setFilteredItems(items.filter(item => item.text.toLowerCase().startsWith(query.toLowerCase()))) - setLoading(false) }, 2000) as unknown as number } const onOpenChange = (value: boolean) => { - setLoading(true) setOpen(value) fetchItems('') } - const loadingProps = { - initialLoadingType, - ...(componentManagesLoading ? {} : {loading}), - } - return ( = { onFilterChange={fetchItems} showItemDividers={true} height={height} - {...loadingProps} + initialLoadingType={initialLoadingType} /> ) }, args: { initialLoadingType: 'spinner', height: 'medium', - componentManagesLoading: true, }, argTypes: { initialLoadingType: { @@ -563,10 +550,5 @@ export const AsyncFetch: StoryObj = { control: 'select', options: ['auto', 'xsmall', 'small', 'medium', 'large', 'xlarge'], }, - componentManagesLoading: { - control: { - type: 'boolean', - }, - }, }, }