Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controlled combobox data #232

Merged
merged 8 commits into from
Feb 1, 2024
Prev Previous commit
Next Next commit
fix(combobox): fix missing prop assertion logic
  • Loading branch information
coopbri committed Feb 1, 2024
commit d3c144bc795febb6b9a6c57845486873557e1adb
11 changes: 4 additions & 7 deletions src/components/core/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export interface Props
};
/** Custom content render override. */
content?: ReactNode;
groups: Group[];
/** Groups of items to display. */
groups?: Group[];
itemIndicator?: boolean;
triggerEnabled?: boolean;
inputProps?: Omit<InputProps, "size">;
Expand All @@ -89,12 +90,8 @@ const Combobox = ({
const allItems = groups.flatMap((group) => group.items);
const [filteredItems, setFilteredItems] = useState(allItems);

// We could throw an error here like so (for descriptiive runtime error purposes):
// if (controlledItems && !setControlledItems) {
// throw new Error(
// "You must provide a `setControlledItems` callback when using `controlledItems`.",
// );
// }
if (!content || !groups)
throw new Error("Either the `content` or `groups` prop must be provided.");

const handleChange = (
evt: Parameters<
Expand Down