Skip to content

Commit

Permalink
Fix SelectionList.stories.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
JKobrynski committed Mar 8, 2024
1 parent 50d743b commit 23de4fd
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/stories/SelectionList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import React, {useMemo, useState} from 'react';
import Badge from '@components/Badge';
import SelectionList from '@components/SelectionList';
import RadioListItem from '@components/SelectionList/RadioListItem';
import type {BaseSelectionListProps, ListItem} from '@components/SelectionList/types';
import withNavigationFallback from '@components/withNavigationFallback';
// eslint-disable-next-line no-restricted-imports
import {defaultStyles} from '@styles/index';
import CONST from '@src/CONST';
import withNavigationFallback from '@components/withNavigationFallback';
import type { BaseSelectionListProps, ListItem } from '@components/SelectionList/types';

const SelectionListWithNavigation = withNavigationFallback(SelectionList);

Expand Down Expand Up @@ -110,18 +110,15 @@ function WithTextInput(props: BaseSelectionListProps<ListItem>) {
const [selectedIndex, setSelectedIndex] = useState(1);

const sections = props.sections.map((section) => {
const data = section.data.reduce<Array<ListItem & {isSelected: boolean}>>(
(memo, item, index) => {
if (!item.text.toLowerCase().includes(searchText.trim().toLowerCase())) {
return memo;
}

const isSelected = selectedIndex === index + (section?.indexOffset ?? 0);
memo.push({...item, isSelected});
const data = section.data.reduce<Array<ListItem & {isSelected: boolean}>>((memo, item, index) => {
if (!item.text.toLowerCase().includes(searchText.trim().toLowerCase())) {
return memo;
},
[],
);
}

const isSelected = selectedIndex === index + (section?.indexOffset ?? 0);
memo.push({...item, isSelected});
return memo;
}, []);

return {...section, data};
});
Expand Down Expand Up @@ -207,6 +204,7 @@ function WithAlternateText(props: BaseSelectionListProps<ListItem>) {
{...props}
sections={sections}
onSelectRow={onSelectRow}
ListItem={RadioListItem}
/>
);
}
Expand Down Expand Up @@ -412,4 +410,4 @@ WithConfirmButton.args = {
};

export {Default, WithTextInput, WithHeaderMessage, WithAlternateText, MultipleSelection, WithSectionHeader, WithConfirmButton};
export default story;
export default story;

0 comments on commit 23de4fd

Please sign in to comment.