Skip to content

Commit

Permalink
fix: properly search for licenses in the combo box
Browse files Browse the repository at this point in the history
  • Loading branch information
bfabio committed Jan 31, 2024
1 parent b104487 commit 718e54f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/app/form/widgets/ComboBoxWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ import Info from "../../components/Info";
import { useController, useFormContext } from "react-hook-form";
import { get } from "lodash";

const filterTextAndValues = (item, search) => {
const text = item.text.toLowerCase();
const needle = search.toLowerCase();

if (text.includes(needle)) {
return true;
}

const value = item.value.toLowerCase();

return value.includes(search);
}

const ComboBoxWidget = (props) => {
const name = props.fieldName;
const id = `field-${name}`;
Expand All @@ -30,10 +43,9 @@ const ComboBoxWidget = (props) => {
id={id}
ref={ref}
data={props.schema.items.enum}
onChange={(v) => inputProps.onChange(v.value)}
dataKey="value"
textField="text"
filter="contains"
filter={filterTextAndValues}
/>

{invalid && (
Expand Down

0 comments on commit 718e54f

Please sign in to comment.