diff --git a/docs/demo/search.md b/docs/demo/search.md new file mode 100644 index 000000000..62ed2a28f --- /dev/null +++ b/docs/demo/search.md @@ -0,0 +1,8 @@ +--- +title: search +nav: + title: Demo + path: /demo +--- + + diff --git a/docs/examples/search.tsx b/docs/examples/search.tsx new file mode 100644 index 000000000..b837655bf --- /dev/null +++ b/docs/examples/search.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import Select, { Option } from '@rc-component/select'; +import '../../assets/index.less'; + +const Demo = () => { + return ( + + ); +}; + +export default Demo; diff --git a/src/BaseSelect/index.tsx b/src/BaseSelect/index.tsx index 788ecd051..6625ef3c6 100644 --- a/src/BaseSelect/index.tsx +++ b/src/BaseSelect/index.tsx @@ -463,15 +463,16 @@ const BaseSelect = React.forwardRef((props, ref) // KeyDown const onInternalKeyDown: React.KeyboardEventHandler = (event) => { const clearLock = getClearLock(); - const { key } = event; + const { key, target } = event; const isEnterKey = key === 'Enter'; const isSpaceKey = key === ' '; + const isTypingInput = (target as HTMLElement)?.tagName === 'INPUT'; // Enter or Space opens dropdown (ARIA combobox: spacebar should open) if (isEnterKey || isSpaceKey) { // Do not submit form when type in the input; prevent Space from scrolling page - if (mode !== 'combobox') { + if (!isTypingInput && mode !== 'combobox') { event.preventDefault(); }