diff --git a/src/Selector/SingleSelector.tsx b/src/Selector/SingleSelector.tsx index b6123a7a2..86768b2fd 100644 --- a/src/Selector/SingleSelector.tsx +++ b/src/Selector/SingleSelector.tsx @@ -63,6 +63,18 @@ const SingleSelector: React.FC = (props) => { ? item.label.toString() : undefined; + const renderPlaceholder = () => { + if (item) { + return null; + } + const hiddenStyle = hasTextInput ? { visibility: 'hidden' as const } : undefined; + return ( + + {placeholder} + + ); + }; + return ( <> @@ -101,9 +113,7 @@ const SingleSelector: React.FC = (props) => { )} {/* Display placeholder */} - {!item && !hasTextInput && ( - {placeholder} - )} + {renderPlaceholder()} ); }; diff --git a/src/index.ts b/src/index.ts index 686e2d739..74bfc799f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,10 @@ -import Select, { ExportedSelectProps as SelectProps } from './Select'; -import { RefSelectProps } from './generate'; +import Select from './Select'; import Option from './Option'; import OptGroup from './OptGroup'; +import type { ExportedSelectProps as SelectProps } from './Select'; +import type { RefSelectProps } from './generate'; -export { Option, OptGroup, SelectProps, RefSelectProps }; +export { Option, OptGroup }; +export type { SelectProps, RefSelectProps }; export default Select; diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index dd808cd85..598533b1d 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -1615,9 +1615,14 @@ describe('Select.Basic', () => { describe('show placeholder', () => { it('when searchValue is controlled', () => { const wrapper = mount(