Skip to content

Commit

Permalink
Fix fuzzy search (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonLim8890 authored Apr 13, 2024
1 parent 7a5ee03 commit 5dc8e34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/frontend/components/Form/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const PlanSelect: React.FC<PlanSelectProps> = ({
? (option: FilterOptionOption<any>, inputValue: string) => {
if (inputValue.length !== 0) {
const list = new Fuse(options, {
keys: ["value"],
isCaseSensitive: false,
shouldSort: true,
ignoreLocation: true,
Expand All @@ -60,7 +61,7 @@ export const PlanSelect: React.FC<PlanSelectProps> = ({
threshold: 0.4,
}).search(inputValue);
return list
.map((element) => element.item)
.map((element) => element.item.value)
.includes(option.data.value);
} else {
return true;
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/components/Plan/AddPlanModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ export const AddPlanModal: React.FC<AddPlanModalProps> = ({
isConcentrationRequired &&
"Concentration is required",
}}
isSearchable
useFuzzySearch
/>
)}
{majorName && !isValidatedMajor && (
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/components/Plan/EditPlanModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export const EditPlanModal: React.FC<EditPlanModalProps> = ({ plan }) => {
}}
rules={{ required: "Major is required." }}
isSearchable
useFuzzySearch
isDisabled={!catalogYear}
/>
{majorHasConcentrations && (
Expand All @@ -318,6 +319,8 @@ export const EditPlanModal: React.FC<EditPlanModalProps> = ({ plan }) => {
isConcentrationRequired &&
"Concentration is required",
}}
isSearchable
useFuzzySearch
/>
)}
{majorName && !isValidatedMajor && (
Expand Down

0 comments on commit 5dc8e34

Please sign in to comment.