Skip to content

Commit

Permalink
fix(Select): fix onEnter callback (#1789)
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn authored Dec 8, 2022
1 parent 1465d07 commit 9a3ddb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/select/_example/filterable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const FilterableSelect = () => {
console.log('handleFocus: ', value, e);
};

const handleEnter = (context) => {
console.log('handleEnter: ', context);
};

return (
<Space breakLine style={{ width: '100%' }}>
<Select
Expand All @@ -45,6 +49,7 @@ const FilterableSelect = () => {
style={{ width: '400px', display: 'inline-block' }}
onBlur={handleBlur}
onFocus={handleFocus}
onEnter={handleEnter}
>
{options.map((option, index) => (
<Option key={index} value={option.value} label={option.label}></Option>
Expand Down
7 changes: 5 additions & 2 deletions src/select/base/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, Ref, useMemo } from 'react';
import React, { useEffect, Ref, useMemo, KeyboardEvent } from 'react';
import classNames from 'classnames';
import isFunction from 'lodash/isFunction';
import get from 'lodash/get';
Expand Down Expand Up @@ -345,6 +345,9 @@ const Select = forwardRefWithStatics(

const { onMouseEnter, onMouseLeave } = props;

const handleEnter = (_, context: { inputValue: string; e: KeyboardEvent<HTMLDivElement> }) => {
onEnter?.({ ...context, value });
};
return (
<div
className={classNames(`${name}__wrap`, className)}
Expand Down Expand Up @@ -391,7 +394,7 @@ const Select = forwardRefWithStatics(
onTagChange={onTagChange}
onInputChange={handleInputChange}
onFocus={onFocus}
onEnter={onEnter}
onEnter={handleEnter}
onBlur={onBlur}
onClear={(context) => {
onClearValue(context);
Expand Down

0 comments on commit 9a3ddb3

Please sign in to comment.