Skip to content

Commit a5bb25a

Browse files
authored
docs(VariantManagement): fix "in FilterBar" story (#6623)
1 parent 66a13ad commit a5bb25a

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

packages/main/src/components/VariantManagement/VariantManagement.mdx

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ function FilterBarWithVariantManagement() {
268268
const hasChanged = Object.entries(initialVariantValues.current[selectedVariant]).some(([key, val]) => {
269269
if (key === 'selectedCodes') {
270270
const selectedCodesLength = Object.keys(filters.selectedCodes).length;
271-
if (selectedCodesLength > 0 && Object.keys(val).length !== selectedCodesLength) {
271+
if (Object.keys(val).length !== selectedCodesLength) {
272272
return true;
273273
}
274274
return Object.entries(filters.selectedCodes).some(([code, bool]) => {
275-
return val[code] !== bool;
275+
return val?.[code] !== bool;
276276
});
277277
}
278278
return filters[key] !== val;
@@ -319,7 +319,7 @@ function FilterBarWithVariantManagement() {
319319
</VariantManagement>
320320
}
321321
>
322-
<FilterGroupItem label="Countries">
322+
<FilterGroupItem label="Countries" filterKey={0}>
323323
<Select onChange={handleSelectChange}>
324324
<Option selected={selectedCountry === 'Indonesia'}>Indonesia</Option>
325325
<Option selected={selectedCountry === 'Costa Rica'}>Costa Rica</Option>
@@ -331,10 +331,10 @@ function FilterBarWithVariantManagement() {
331331
<Option selected={selectedCountry === 'Austria'}>Austria</Option>
332332
</Select>
333333
</FilterGroupItem>
334-
<FilterGroupItem label="Date">
334+
<FilterGroupItem label="Date" filterKey={1}>
335335
<DatePicker value={date} onChange={handleDateChange} />
336336
</FilterGroupItem>
337-
<FilterGroupItem label="Company Code">
337+
<FilterGroupItem label="Company Code" filterKey={2}>
338338
<MultiComboBox onSelectionChange={handleSelectedCodesChange}>
339339
<MultiComboBoxItem text="001" selected={selectedCodes['001']} data-code="001" />
340340
<MultiComboBoxItem text="002" selected={selectedCodes['002']} data-code="002" />
@@ -344,27 +344,20 @@ function FilterBarWithVariantManagement() {
344344
</MultiComboBox>
345345
</FilterGroupItem>
346346
</FilterBar>
347-
<Form
348-
style={{ marginBlockStart: '2rem' }}
349-
columnsS={1}
350-
columnsM={1}
351-
columnsL={1}
352-
columnsXL={1}
353-
labelSpanM={2}
354-
labelSpanL={2}
355-
labelSpanXL={2}
356-
>
357-
<FormItem label="Current View">
358-
<Text>{selectedVariant}</Text>
359-
</FormItem>
360-
<FormGroup titleText="Filters">
361-
<FormItem label="Selected Country">
347+
<Form style={{ marginBlockStart: '2rem' }} layout={'S1 M1 L1 XL1'} labelSpan={'S3 M3 L3 XL3'}>
348+
<FormGroup headerText="Variant">
349+
<FormItem labelContent={<Label showColon>Current View</Label>}>
350+
<Text>{selectedVariant}</Text>
351+
</FormItem>
352+
</FormGroup>
353+
<FormGroup headerText="Filters">
354+
<FormItem labelContent={<Label showColon>Selected Country</Label>}>
362355
<Text>{selectedCountry}</Text>
363356
</FormItem>
364-
<FormItem label="Selected Date">
357+
<FormItem labelContent={<Label showColon>Selected Date</Label>}>
365358
<Text>{date}</Text>
366359
</FormItem>
367-
<FormItem label="Selected Company Codes">
360+
<FormItem labelContent={<Label showColon>Selected Company Codes</Label>}>
368361
<Text>{Object.keys(selectedCodes).join(', ')}</Text>
369362
</FormItem>
370363
</FormGroup>

packages/main/src/components/VariantManagement/VariantManagement.stories.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export const WithFilterBarImplementation: Story = {
324324
</VariantManagement>
325325
}
326326
>
327-
<FilterGroupItem label="Countries">
327+
<FilterGroupItem label="Countries" filterKey={0}>
328328
<Select onChange={handleSelectChange}>
329329
<Option selected={selectedCountry === 'Indonesia'}>Indonesia</Option>
330330
<Option selected={selectedCountry === 'Costa Rica'}>Costa Rica</Option>
@@ -336,10 +336,10 @@ export const WithFilterBarImplementation: Story = {
336336
<Option selected={selectedCountry === 'Austria'}>Austria</Option>
337337
</Select>
338338
</FilterGroupItem>
339-
<FilterGroupItem label="Date">
339+
<FilterGroupItem label="Date" filterKey={1}>
340340
<DatePicker value={date} onChange={handleDateChange} />
341341
</FilterGroupItem>
342-
<FilterGroupItem label="Company Code">
342+
<FilterGroupItem label="Company Code" filterKey={2}>
343343
<MultiComboBox onSelectionChange={handleSelectedCodesChange}>
344344
<MultiComboBoxItem text="001" selected={selectedCodes['001']} data-code="001" />
345345
<MultiComboBoxItem text="002" selected={selectedCodes['002']} data-code="002" />
@@ -349,18 +349,20 @@ export const WithFilterBarImplementation: Story = {
349349
</MultiComboBox>
350350
</FilterGroupItem>
351351
</FilterBar>
352-
<Form style={{ marginBlockStart: '2rem' }} layout={'S1 M1 L1 XL1'} labelSpan={'M2 L2 XL2'}>
353-
<FormItem labelContent={<Label>Current View</Label>}>
354-
<Text>{selectedVariant}</Text>
355-
</FormItem>
352+
<Form style={{ marginBlockStart: '2rem' }} layout={'S1 M1 L1 XL1'} labelSpan={'S3 M3 L3 XL3'}>
353+
<FormGroup headerText="Variant">
354+
<FormItem labelContent={<Label showColon>Current View</Label>}>
355+
<Text>{selectedVariant}</Text>
356+
</FormItem>
357+
</FormGroup>
356358
<FormGroup headerText="Filters">
357-
<FormItem labelContent={<Label>Selected Country</Label>}>
359+
<FormItem labelContent={<Label showColon>Selected Country</Label>}>
358360
<Text>{selectedCountry}</Text>
359361
</FormItem>
360-
<FormItem labelContent={<Label>Selected Date</Label>}>
362+
<FormItem labelContent={<Label showColon>Selected Date</Label>}>
361363
<Text>{date}</Text>
362364
</FormItem>
363-
<FormItem labelContent={<Label>Selected Company Codes</Label>}>
365+
<FormItem labelContent={<Label showColon>Selected Company Codes</Label>}>
364366
<Text>{Object.keys(selectedCodes).join(', ')}</Text>
365367
</FormItem>
366368
</FormGroup>

0 commit comments

Comments
 (0)