Skip to content

Commit

Permalink
fix(dropdown): dropdown keydown error (#1653)
Browse files Browse the repository at this point in the history
  • Loading branch information
berber1016 committed Dec 8, 2021
1 parent eb25fc2 commit 0759445
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { cloneElement, Children, forwardRef } from 'react';
import classnames from 'classnames';
import { usePrefixCls } from '@gio-design/utils';
import { isFunction, isUndefined } from 'lodash';
import { isFunction, isUndefined, noop } from 'lodash';
import DropdownProps from './interface';
import useControlledState from '../utils/hooks/useControlledState';
import Popover from '../popover';
Expand Down Expand Up @@ -56,19 +56,9 @@ export const Dropdown = forwardRef<HTMLDivElement, DropdownProps>((props, ref) =
}
};
const onClick = close;
const onKeyDown = ({ key }: React.KeyboardEvent<HTMLDivElement>) => {
if ([' ', 'Enter', 'Escape'].includes(key)) {
close();
}
};

return (
<div
role="button"
ref={ref}
tabIndex={0}
onClick={isUndefined(visible) ? onClick : undefined}
onKeyDown={onKeyDown}
>
<div role="none" ref={ref} onKeyDown={noop} onClick={isUndefined(visible) ? onClick : noop}>
{contentNode}
</div>
);
Expand Down

1 comment on commit 0759445

@vercel
Copy link

@vercel vercel bot commented on 0759445 Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.