Skip to content

Commit

Permalink
chore(select): 代码简化(#2809)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiamiao committed May 9, 2024
1 parent 613c15a commit 99c8d84
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/ui/select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,11 @@ export const Select = forwardRef<HTMLDivElement | null, SelectProps>(
const defaultIndex = showData.findIndex((item: SelectDataItem) => !item.disabled)

const [focusedIndex, setFocusedIndex] = useState<number>(defaultIndex)
const [isComposing, setIsComposing] = useState<boolean>(false)

const handleKeyDown = useLatestCallback((evt: React.KeyboardEvent) => {
const { key } = evt
const { keyCode } = evt

if (key === 'Enter' && !isComposing) {
if (keyCode === 13) {
const item = showData[focusedIndex]

if (item) {
Expand Down Expand Up @@ -236,12 +235,6 @@ export const Select = forwardRef<HTMLDivElement | null, SelectProps>(
onKeyDown={mockDefaultHandlers(handleKeyDown, onKeyDownProp)}
onOpen={menuVisibleAction.on}
onClose={menuVisibleAction.off}
onCompositionStart={() => {
setIsComposing(true)
}}
onCompositionEnd={() => {
setIsComposing(false)
}}
searchable={searchable}
keyword={keywordProp}
onSearch={callAllFuncs(onSearchProp, onSearch)}
Expand Down

0 comments on commit 99c8d84

Please sign in to comment.