From b02bde8e9ae37b39c0c2ebbcfd8aa391ee67d34d Mon Sep 17 00:00:00 2001 From: Jon Maxwell Diebold Date: Wed, 24 Jan 2024 14:34:04 -0500 Subject: [PATCH 1/2] HMW-664 Fixed array access bug in characteristics select menu --- app/client/src/components/shared/PaginatedSelect.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/client/src/components/shared/PaginatedSelect.tsx b/app/client/src/components/shared/PaginatedSelect.tsx index c3351ca5c..c210974c3 100644 --- a/app/client/src/components/shared/PaginatedSelect.tsx +++ b/app/client/src/components/shared/PaginatedSelect.tsx @@ -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]); @@ -69,7 +69,8 @@ export function PaginatedSelect(props: Props) { const optionsOrGroupsPage = useMemo(() => { const page = filteredOptions.slice(startIndex, startIndex + PAGE_SIZE * 2); - return 'options' in optionsOrGroups + const optionOrGroup = optionsOrGroups[0]; + return optionOrGroup && 'options' in optionOrGroup ? [{ label: 'Group', options: page }] : page; }, [filteredOptions, optionsOrGroups, startIndex]); From 8cd9cb88715d05c023d7dd2b70abef64ed82c4a3 Mon Sep 17 00:00:00 2001 From: Jon Maxwell Diebold Date: Wed, 24 Jan 2024 15:04:59 -0500 Subject: [PATCH 2/2] HMW-664 Added a comment --- app/client/src/components/shared/PaginatedSelect.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/app/client/src/components/shared/PaginatedSelect.tsx b/app/client/src/components/shared/PaginatedSelect.tsx index c210974c3..6f5690a69 100644 --- a/app/client/src/components/shared/PaginatedSelect.tsx +++ b/app/client/src/components/shared/PaginatedSelect.tsx @@ -69,6 +69,7 @@ export function PaginatedSelect(props: Props) { const optionsOrGroupsPage = useMemo(() => { const page = filteredOptions.slice(startIndex, startIndex + PAGE_SIZE * 2); + // 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 }]