Skip to content

Commit

Permalink
Merge pull request #866 from CodeForPhilly/staging
Browse files Browse the repository at this point in the history
Deploy Staging to Main branch (bugfix)
  • Loading branch information
CodeWritingCow authored Aug 8, 2024
2 parents 070084c + 4373dde commit 477e0f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
15 changes: 13 additions & 2 deletions src/components/Filters/DimensionFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,19 @@ const DimensionFilter: FC<DimensionFilterProps> = ({
});
};

const handleSelectionChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const newMultiSelect: string[] = e.target.value.split(',');
const handleSelectionChange = (
selection: React.ChangeEvent<HTMLSelectElement> | string
) => {
let newMultiSelect: string[] = [];
if (typeof selection === 'string') {
newMultiSelect = selectedKeys.includes(selection)
? selectedKeys.filter((key) => key !== selection)
: [...selectedKeys, selection];
} else {
if (selection.target.value !== '') {
newMultiSelect = selection.target.value.split(',');
}
}
setSelectedKeys(newMultiSelect);
dispatch({
type: 'SET_DIMENSIONS',
Expand Down
14 changes: 5 additions & 9 deletions src/components/Filters/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ type MultiSelectProps = {
options: any[];
selectedKeys: string[];
toggleDimension: (dimension: string) => void;
handleSelectionChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
handleSelectionChange: (
selection: React.ChangeEvent<HTMLSelectElement> | string
) => void;
};

const MultiSelect: FC<MultiSelectProps> = ({
Expand All @@ -24,12 +26,6 @@ const MultiSelect: FC<MultiSelectProps> = ({
toggleDimension,
handleSelectionChange,
}) => {
const multiSelectOptions = options.filter((option) => {
if (!selectedKeys.includes(option)) {
return option;
}
});

return (
<div className="space-x-2 min-h-[33.5px]">
<SelectFilter
Expand All @@ -51,7 +47,7 @@ const MultiSelect: FC<MultiSelectProps> = ({
key={index}
classNames={{ base: 'multiSelectChip' }}
endContent={<X aria-label={`close ${option}`} />}
onClose={() => toggleDimension(option)}
onClose={() => handleSelectionChange(option)}
>
{option}
</SelectFilterChip>
Expand All @@ -61,7 +57,7 @@ const MultiSelect: FC<MultiSelectProps> = ({
}}
onChange={handleSelectionChange}
>
{multiSelectOptions.map((option) => (
{options.map((option) => (
<SelectFilterItem
key={option}
value={option}
Expand Down

0 comments on commit 477e0f0

Please sign in to comment.