Skip to content

Commit 51a498c

Browse files
committed
fix: Select value={0} should not be filtered
#590 (comment)
1 parent 743f076 commit 51a498c

17 files changed

+64
-69
lines changed

examples/custom-tags.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React from 'react';
33
import Select, { Option } from '../src';
44
import '../assets/index.less';
5-
import { CustomTagProps } from '../src/interface/generator';
5+
import type { CustomTagProps } from '../src/interface/generator';
66

77
const children = [];
88
for (let i = 10; i < 36; i += 1) {

src/OptGroup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* istanbul ignore file */
2-
import * as React from 'react';
3-
import { OptionGroupData } from './interface';
2+
import type * as React from 'react';
3+
import type { OptionGroupData } from './interface';
44

55
export interface OptGroupProps extends Omit<OptionGroupData, 'options'> {
66
children?: React.ReactNode;

src/Option.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* istanbul ignore file */
2-
import * as React from 'react';
3-
import { OptionCoreData } from './interface';
2+
import type * as React from 'react';
3+
import type { OptionCoreData } from './interface';
44

55
export interface OptionProps extends Omit<OptionCoreData, 'label'> {
66
children: React.ReactNode;

src/OptionList.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ import KeyCode from 'rc-util/lib/KeyCode';
33
import pickAttrs from 'rc-util/lib/pickAttrs';
44
import useMemo from 'rc-util/lib/hooks/useMemo';
55
import classNames from 'classnames';
6-
import List, { ListRef } from 'rc-virtual-list';
6+
import type { ListRef } from 'rc-virtual-list';
7+
import List from 'rc-virtual-list';
78
import TransBtn from './TransBtn';
8-
import {
9+
import type {
910
OptionsType as SelectOptionsType,
1011
FlattenOptionData as SelectFlattenOptionData,
1112
OptionData,
1213
RenderNode,
1314
OnActiveValue,
1415
} from './interface';
15-
import { RawValueType, FlattenOptionsType } from './interface/generator';
16+
import type { RawValueType, FlattenOptionsType } from './interface/generator';
1617

1718
export interface OptionListProps<OptionsType extends object[]> {
1819
prefixCls: string;
@@ -89,7 +90,7 @@ const OptionList: React.RefForwardingComponent<
8990
// =========================== List ===========================
9091
const listRef = React.useRef<ListRef>(null);
9192

92-
const onListMouseDown: React.MouseEventHandler<HTMLDivElement> = event => {
93+
const onListMouseDown: React.MouseEventHandler<HTMLDivElement> = (event) => {
9394
event.preventDefault();
9495
};
9596

@@ -176,7 +177,7 @@ const OptionList: React.RefForwardingComponent<
176177

177178
// ========================= Keyboard =========================
178179
React.useImperativeHandle(ref, () => ({
179-
onKeyDown: event => {
180+
onKeyDown: (event) => {
180181
const { which } = event;
181182
switch (which) {
182183
// >>> Arrow keys
@@ -226,7 +227,7 @@ const OptionList: React.RefForwardingComponent<
226227
},
227228
onKeyUp: () => {},
228229

229-
scrollTo: index => {
230+
scrollTo: (index) => {
230231
scrollIntoView(index);
231232
},
232233
}));

src/Select.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131

3232
import * as React from 'react';
33-
import { OptionsType as SelectOptionsType } from './interface';
33+
import type { OptionsType as SelectOptionsType } from './interface';
3434
import SelectOptionList from './OptionList';
3535
import Option from './Option';
3636
import OptGroup from './OptGroup';
@@ -43,8 +43,9 @@ import {
4343
flattenOptions,
4444
fillOptionsWithMissingValue,
4545
} from './utils/valueUtil';
46-
import generateSelector, { SelectProps, RefSelectProps } from './generate';
47-
import { DefaultValueType } from './interface/generator';
46+
import type { SelectProps, RefSelectProps } from './generate';
47+
import generateSelector from './generate';
48+
import type { DefaultValueType } from './interface/generator';
4849
import warningProps from './utils/warningPropsUtil';
4950

5051
const RefSelect = generateSelector<SelectOptionsType>({

src/SelectTrigger.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import Trigger from 'rc-trigger';
33
import classNames from 'classnames';
4-
import { RenderDOMFunc } from './interface';
4+
import type { RenderDOMFunc } from './interface';
55

66
const getBuiltInPlacements = (dropdownMatchSelectWidth: number | boolean) => {
77
// Enable horizontal overflow auto-adjustment when a custom dropdown width is provided

src/Selector/MultipleSelector.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import classNames from 'classnames';
44
import pickAttrs from 'rc-util/lib/pickAttrs';
55
import Overflow from 'rc-overflow';
66
import TransBtn from '../TransBtn';
7-
import {
7+
import type {
88
LabelValueType,
99
DisplayLabelValueType,
1010
RawValueType,
1111
CustomTagProps,
1212
DefaultValueType,
1313
} from '../interface/generator';
14-
import { RenderNode } from '../interface';
15-
import { InnerSelectorProps } from '.';
14+
import type { RenderNode } from '../interface';
15+
import type { InnerSelectorProps } from '.';
1616
import Input from './Input';
1717
import useLayoutEffect from '../hooks/useLayoutEffect';
1818

@@ -39,7 +39,7 @@ const onPreventMouseDown = (event: React.MouseEvent) => {
3939
event.preventDefault();
4040
event.stopPropagation();
4141
};
42-
const SelectSelector: React.FC<SelectorProps> = props => {
42+
const SelectSelector: React.FC<SelectorProps> = (props) => {
4343
const {
4444
id,
4545
prefixCls,

src/Selector/SingleSelector.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import * as React from 'react';
22
import pickAttrs from 'rc-util/lib/pickAttrs';
33
import Input from './Input';
4-
import { InnerSelectorProps } from '.';
4+
import type { InnerSelectorProps } from '.';
55

66
interface SelectorProps extends InnerSelectorProps {
77
inputElement: React.ReactElement;
88
activeValue: string;
99
backfill?: boolean;
1010
}
1111

12-
const SingleSelector: React.FC<SelectorProps> = props => {
12+
const SingleSelector: React.FC<SelectorProps> = (props) => {
1313
const {
1414
inputElement,
1515
prefixCls,
@@ -80,7 +80,7 @@ const SingleSelector: React.FC<SelectorProps> = props => {
8080
value={inputValue}
8181
onKeyDown={onInputKeyDown}
8282
onMouseDown={onInputMouseDown}
83-
onChange={e => {
83+
onChange={(e) => {
8484
setInputChanged(true);
8585
onInputChange(e as any);
8686
}}

src/TransBtn.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
3-
import { RenderNode } from './interface';
3+
import type { RenderNode } from './interface';
44

55
export interface TransBtnProps {
66
className: string;
@@ -30,7 +30,7 @@ const TransBtn: React.FC<TransBtnProps> = ({
3030
return (
3131
<span
3232
className={className}
33-
onMouseDown={event => {
33+
onMouseDown={(event) => {
3434
event.preventDefault();
3535
if (onMouseDown) {
3636
onMouseDown(event);
@@ -47,7 +47,7 @@ const TransBtn: React.FC<TransBtnProps> = ({
4747
{icon !== undefined ? (
4848
icon
4949
) : (
50-
<span className={classNames(className.split(/\s+/).map(cls => `${cls}-icon`))}>
50+
<span className={classNames(className.split(/\s+/).map((cls) => `${cls}-icon`))}>
5151
{children}
5252
</span>
5353
)}

src/hooks/useCacheDisplayValue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { DisplayLabelValueType } from '../interface/generator';
2+
import type { DisplayLabelValueType } from '../interface/generator';
33

44
export default function useCacheDisplayValue(
55
values: DisplayLabelValueType[],
@@ -15,7 +15,7 @@ export default function useCacheDisplayValue(
1515
}
1616
});
1717

18-
const resultValues = values.map(item => {
18+
const resultValues = values.map((item) => {
1919
const cacheLabel = valueLabels.get(item.value);
2020
if (item.isCacheable && cacheLabel) {
2121
return {

0 commit comments

Comments
 (0)