Skip to content

Commit

Permalink
Merge pull request #936 from Eastern-Research-Group/bugfix/664_restor…
Browse files Browse the repository at this point in the history
…e-characterstics-select-header

HMW-664 Fixed array access bug in characteristics select menu
  • Loading branch information
cschwinderg authored Jan 25, 2024
2 parents 5dcdc67 + 8cd9cb8 commit ba4094d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/client/src/components/shared/PaginatedSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export function PaginatedSelect(props: Props) {
const { options: optionsOrGroups, styles, ...rest } = props;

const options = useMemo(() => {
return optionsOrGroups.flatMap((groupOrOption) => {
if ('options' in groupOrOption) return groupOrOption.options;
return groupOrOption;
return optionsOrGroups.flatMap((optionOrGroup) => {
if ('options' in optionOrGroup) return optionOrGroup.options;
return optionOrGroup;
});
}, [optionsOrGroups]);

Expand Down Expand Up @@ -69,7 +69,9 @@ export function PaginatedSelect(props: Props) {

const optionsOrGroupsPage = useMemo(() => {
const page = filteredOptions.slice(startIndex, startIndex + PAGE_SIZE * 2);
return 'options' in optionsOrGroups
// A group is only used in one place, so we can get away with only checking the first item.
const optionOrGroup = optionsOrGroups[0];
return optionOrGroup && 'options' in optionOrGroup
? [{ label: 'Group', options: page }]
: page;
}, [filteredOptions, optionsOrGroups, startIndex]);
Expand Down

0 comments on commit ba4094d

Please sign in to comment.