Skip to content

Commit

Permalink
fix(Picker): fixed the issue with virtual focus when filtering the li…
Browse files Browse the repository at this point in the history
…st (#1267)
  • Loading branch information
marcinsawicki authored Jul 31, 2024
1 parent a12dffe commit 0e4fd96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-components/src/components/Picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const Picker: React.FC<IPickerProps> = ({
useDismissHookProps,
isOpen,
onVisibilityChange: handleVisibilityChange,
searchPhrase,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface UseFloatingPickerProps {
maxListHeight: number;
isOpen?: boolean;
onVisibilityChange?: (open: boolean, event?: Event | undefined) => void;
searchPhrase?: string;
}

interface IUseFloatingPicker {
Expand Down Expand Up @@ -75,6 +76,7 @@ export const useFloatingPicker = ({
useClickHookProps,
isOpen,
onVisibilityChange,
searchPhrase,
}: UseFloatingPickerProps): IUseFloatingPicker => {
const nodeId = useFloatingNodeId();
const [pointer, setPointer] = React.useState(false);
Expand All @@ -83,6 +85,11 @@ export const useFloatingPicker = ({
const listElementsRef = React.useRef<Array<HTMLElement | null>>([]);
const virtualItemRef = React.useRef(null);

React.useEffect(() => {
virtualItemRef.current = null;
setActiveIndex(null);
}, [searchPhrase]);

const { refs, floatingStyles, context, isPositioned } =
useFloating<HTMLButtonElement>({
nodeId,
Expand Down

0 comments on commit 0e4fd96

Please sign in to comment.