Skip to content

Commit 95fea7c

Browse files
authored
Revert "fix: use strict null/undefined check for display value in single select (#1205)" (#1206)
This reverts commit f781118.
1 parent e68b129 commit 95fea7c

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/SelectInput/Content/SingleContent.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const SingleContent = React.forwardRef<HTMLInputElement, SharedContentProps>(
1919

2020
const combobox = mode === 'combobox';
2121
const displayValue = displayValues[0];
22-
const hasDisplayValue = displayValue !== null && displayValue !== undefined;
2322

2423
// Implement the same logic as the old SingleSelector
2524
const mergedSearchValue = React.useMemo(() => {
@@ -35,7 +34,7 @@ const SingleContent = React.forwardRef<HTMLInputElement, SharedContentProps>(
3534
let style: React.CSSProperties | undefined;
3635
let titleValue: string | undefined;
3736

38-
if (hasDisplayValue && selectContext?.flattenOptions) {
37+
if (displayValue && selectContext?.flattenOptions) {
3938
const option = selectContext.flattenOptions.find((opt) => opt.value === displayValue.value);
4039
if (option?.data) {
4140
className = option.data.className;
@@ -44,7 +43,7 @@ const SingleContent = React.forwardRef<HTMLInputElement, SharedContentProps>(
4443
}
4544
}
4645

47-
if (hasDisplayValue && !titleValue) {
46+
if (displayValue && !titleValue) {
4847
titleValue = getTitle(displayValue);
4948
}
5049

@@ -65,7 +64,7 @@ const SingleContent = React.forwardRef<HTMLInputElement, SharedContentProps>(
6564

6665
// ========================== Render ==========================
6766
// Render value
68-
const renderValue = hasDisplayValue ? (
67+
const renderValue = displayValue ? (
6968
hasOptionStyle ? (
7069
<div
7170
className={clsx(`${prefixCls}-content-value`, optionClassName)}
@@ -89,7 +88,7 @@ const SingleContent = React.forwardRef<HTMLInputElement, SharedContentProps>(
8988
<div
9089
className={clsx(
9190
`${prefixCls}-content`,
92-
hasDisplayValue && `${prefixCls}-content-has-value`,
91+
displayValue && `${prefixCls}-content-has-value`,
9392
mergedSearchValue && `${prefixCls}-content-has-search-value`,
9493
hasOptionStyle && `${prefixCls}-content-has-option-style`,
9594
classNames?.content,

tests/placeholder.test.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,4 @@ describe('Select placeholder', () => {
4040
});
4141
expect(container.querySelector('.rc-select-placeholder').textContent).toBe('placeholder');
4242
});
43-
44-
it('should have content-has-value class when value is empty string', () => {
45-
const { container } = render(
46-
<Select value="" placeholder="placeholder" options={[{ value: '', label: '' }]} />,
47-
);
48-
expect(container.querySelector('.rc-select-content-has-value')).toBeTruthy();
49-
});
5043
});

0 commit comments

Comments
 (0)