Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Scully authored and Sean Scully committed Mar 16, 2024
1 parent 60bfccc commit d272257
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from './filterBar.module.css';
export type FieldOptionOperation = 'equals' | 'includes';

interface ValueFilter {
fieldName: string | ((item: any) => string);
fieldName: string | ((item: Record<string, string>) => string);
operation: FieldOptionOperation;
value: string;
label: string;
Expand Down Expand Up @@ -102,8 +102,10 @@ export const FilterBar = ({ onFilterChange, fields, initialFilters = [] }: Filte
);

useEffect(() => {
setActiveFilters(initialFilters);
onFilterChange(initialFilters);
if (initialFilters.length) {
setActiveFilters(initialFilters);
onFilterChange(initialFilters);
}
}, [initialFilters]);

const handleFilterUpdate = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ interface FilterListItemProps {
disabled?: boolean;
}
export const FilterListItem = ({ children, onClick, disabled }: FilterListItemProps) => {
const handleKeyUp = (event: React.KeyboardEvent<HTMLLIElement>) => {
if (event.key === 'Enter' && !disabled) {
onClick?.();
}
};
return (
<li
onClick={disabled ? undefined : onClick}
className={cx(styles.filterListItem, { [styles.disabled]: disabled })}
tabIndex={0}
onKeyUp={disabled ? undefined : handleKeyUp}
>
{children}
</li>
Expand Down

0 comments on commit d272257

Please sign in to comment.