Skip to content

Commit

Permalink
resetting listbox
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencomsft committed May 17, 2024
1 parent 1345e66 commit 99b050a
Showing 1 changed file with 0 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ export const useListbox_unstable = (props: ListboxProps, ref: React.Ref<HTMLElem

const { clearSelection, selectedOptions, selectOption } = useSelection(props);

const isPointerFocusRef = React.useRef(false);

const onKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {
const action = getDropdownActionFromKey(event, { open: true });
const activeOptionId = activeDescendantController.active();
Expand Down Expand Up @@ -114,17 +112,7 @@ export const useListbox_unstable = (props: ListboxProps, ref: React.Ref<HTMLElem
}
};

const onPointerDown = () => {
isPointerFocusRef.current = true;
};

const onFocus = (_event: React.FocusEvent<HTMLElement>) => {
// skip if pointer-originated focus
if (isPointerFocusRef.current) {
isPointerFocusRef.current = false;
return;
}

if (hasParentActiveDescendantContext || activeDescendantController.active()) {
return;
}
Expand Down Expand Up @@ -200,7 +188,6 @@ export const useListbox_unstable = (props: ListboxProps, ref: React.Ref<HTMLElem
};

state.root.onKeyDown = useEventCallback(mergeCallbacks(state.root.onKeyDown, onKeyDown));
state.root.onPointerDown = useEventCallback(mergeCallbacks(state.root.onPointerDown, onPointerDown));
state.root.onFocus = useEventCallback(mergeCallbacks(state.root.onFocus, onFocus));
state.root.onBlur = useEventCallback(mergeCallbacks(state.root.onBlur, onBlur));

Expand Down

0 comments on commit 99b050a

Please sign in to comment.