Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
fix(core): prevent mousedown event on dropdown to keep it open
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Aug 19, 2020
1 parent 92d95cc commit ec9733b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/autocomplete-core/src/propGetters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,14 @@ export function getPropGetters<TItem, TEvent, TMouseEvent, TKeyboardEvent>({
};
};

const getDropdownProps: GetDropdownProps = (rest) => {
const getDropdownProps: GetDropdownProps<TMouseEvent> = (rest) => {
return {
onMouseDown(event) {
// Prevents the `activeElement` from being changed to the dropdown so
// that the blur event is not triggered, otherwise it closes the
// dropdown.
((event as unknown) as MouseEvent).preventDefault();
},
onMouseLeave() {
store.send('mouseleave', null);
},
Expand Down
3 changes: 2 additions & 1 deletion packages/autocomplete-core/src/types/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ export type GetInputProps<TEvent, TMouseEvent, TKeyboardEvent> = (props: {
onClick(event: TMouseEvent): void;
};

export type GetDropdownProps = (props?: {
export type GetDropdownProps<TMouseEvent> = (props?: {
[key: string]: unknown;
}) => {
onMouseDown(event: TMouseEvent): void;
onMouseLeave(): void;
};

Expand Down

0 comments on commit ec9733b

Please sign in to comment.