Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,8 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP
_,
ref,
) => {
const {
prefixCls,
id,
open,
multiple,
searchValue,
toggleOpen,
notFoundContent,
onPopupScroll,
} = useBaseProps();
const { prefixCls, id, open, multiple, searchValue, toggleOpen, notFoundContent, onPopupScroll } =
useBaseProps();
const {
flattenOptions,
onActiveValue,
Expand Down Expand Up @@ -306,7 +298,8 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP
const iconVisible =
!menuItemSelectedIcon || typeof menuItemSelectedIcon === 'function' || selected;

const content = mergedLabel || value;
// https://github.com/ant-design/ant-design/issues/34145
const content = typeof mergedLabel === 'number' ? mergedLabel : mergedLabel || value;
Copy link
Member

Choose a reason for hiding this comment

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

NaN呢? 感觉判断undefined吧?

// https://github.com/ant-design/ant-design/issues/26717
let optionTitle =
typeof content === 'string' || typeof content === 'number'
Expand Down
19 changes: 19 additions & 0 deletions tests/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,25 @@ describe('Select.Basic', () => {
jest.useRealTimers();
});

it('should render 0 as text properly', () => {
const data = [
{ text: 0, value: '=0' },
{ text: 1, value: '=1' },
];

const wrapper = mount(
<Select style={{ width: 120 }} open>
{data.map((d) => (
<Select.Option value={d.value} key={d.value}>
{d.text}
</Select.Option>
))}
</Select>,
);

expect(wrapper.find('.rc-select-item-option-content').first().text()).toEqual('0');
});

describe('focus', () => {
let handleFocus;
let wrapper;
Expand Down