Skip to content

Commit 46ff2fe

Browse files
committed
fix(ui:selectbox): fix dSearchable not work
1 parent 28cdad5 commit 46ff2fe

5 files changed

Lines changed: 22 additions & 21 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"rfs": "^9.0.6",
4545
"rxjs": "^7.5.5",
4646
"scrollview-resize": "^1.0.2",
47-
"stylelint-config-recess-order": "^3.0.0",
4847
"tslib": "^2.4.0"
4948
},
5049
"devDependencies": {
@@ -95,6 +94,7 @@
9594
"standard-version": "^9.5.0",
9695
"stylelint": "^14.9.0",
9796
"stylelint-config-prettier": "^9.0.3",
97+
"stylelint-config-recess-order": "^3.0.0",
9898
"stylelint-config-recommended-scss": "^6.0.0",
9999
"stylelint-config-standard": "^26.0.0",
100100
"stylelint-scss": "^4.2.0",

packages/ui/src/components/_selectbox/Selectbox.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { DTransition } from '../_transition';
1616

1717
export type DExtendsSelectboxProps = Pick<
1818
DSelectboxProps,
19-
'dFormControl' | 'dPlaceholder' | 'dDisabled' | 'dSearchable' | 'dSize' | 'dLoading' | 'onClear' | 'onVisibleChange'
19+
'dFormControl' | 'dPlaceholder' | 'dDisabled' | 'dSearchable' | 'dSize' | 'dLoading' | 'onClear' | 'onSearch' | 'onVisibleChange'
2020
>;
2121

2222
export interface DSelectboxRenderProps {
@@ -44,6 +44,7 @@ export interface DSelectboxProps extends Omit<React.HTMLAttributes<HTMLDivElemen
4444
dInputProps: React.InputHTMLAttributes<HTMLInputElement> & { 'aria-controls': string };
4545
onVisibleChange?: (visible: boolean) => void;
4646
onFocusVisibleChange?: (visible: boolean) => void;
47+
onSearch?: (value: string) => void;
4748
onClear?: () => void;
4849
}
4950

@@ -67,6 +68,7 @@ export function DSelectbox(props: DSelectboxProps): JSX.Element | null {
6768
dInputProps,
6869
onVisibleChange,
6970
onFocusVisibleChange,
71+
onSearch,
7072
onClear,
7173

7274
className,
@@ -242,7 +244,10 @@ export function DSelectbox(props: DSelectboxProps): JSX.Element | null {
242244
onChange={(e) => {
243245
dInputProps?.onChange?.(e);
244246

245-
setSearchValue(e.currentTarget.value);
247+
if (dSearchable && dVisible) {
248+
setSearchValue(e.currentTarget.value);
249+
onSearch?.(e.currentTarget.value);
250+
}
246251
}}
247252
onKeyDown={(e) => {
248253
dInputProps?.onKeyDown?.(e);

packages/ui/src/components/cascader/Cascader.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export interface DCascaderBaseProps<V extends DId, T extends DCascaderOption<V>>
4646
dAutoMaxWidth?: boolean;
4747
dPopupClassName?: string;
4848
onFocusChange?: (value: V, option: DNestedChildren<T>) => void;
49-
onSearch?: (value: string) => void;
5049
}
5150

5251
export interface DCascaderSingleProps<V extends DId, T extends DCascaderOption<V>> extends DCascaderBaseProps<V, T> {
@@ -86,14 +85,14 @@ export function DCascader<V extends DId, T extends DCascaderOption<V>>(props: DC
8685
dPopupClassName,
8786
onFocusChange,
8887
onModelChange,
89-
onSearch,
9088

9189
dFormControl,
9290
dLoading,
9391
dDisabled,
9492
dSize,
9593
onVisibleChange,
9694
onClear,
95+
onSearch,
9796

9897
className,
9998
...restProps
@@ -371,12 +370,6 @@ export function DCascader<V extends DId, T extends DCascaderOption<V>>(props: DC
371370
dSize={size}
372371
dInputProps={{
373372
'aria-controls': listId,
374-
onChange: (e) => {
375-
const value = e.currentTarget.value;
376-
setSearchValue(value);
377-
378-
onSearch?.(value);
379-
},
380373
onKeyDown: (e) => {
381374
if (visible) {
382375
onKeyDown$.next(e);
@@ -386,6 +379,11 @@ export function DCascader<V extends DId, T extends DCascaderOption<V>>(props: DC
386379
dCustomWidth
387380
dAutoMaxWidth={dAutoMaxWidth}
388381
onClear={handleClear}
382+
onSearch={(value) => {
383+
onSearch?.(value);
384+
385+
setSearchValue(value);
386+
}}
389387
onVisibleChange={changeVisible}
390388
onFocusVisibleChange={setIsFocusVisible}
391389
>

packages/ui/src/components/select/Select.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export interface DSelectBaseProps<V extends DId, T extends DSelectOption<V>>
4040
dPopupClassName?: string;
4141
onScrollBottom?: () => void;
4242
onCreateOption?: (option: DNestedChildren<T>) => void;
43-
onSearch?: (value: string) => void;
4443
}
4544

4645
export interface DSelectSingleProps<V extends DId, T extends DSelectOption<V>> extends DSelectBaseProps<V, T> {
@@ -85,7 +84,6 @@ export function DSelect<V extends DId, T extends DSelectOption<V>>(props: DSelec
8584
onModelChange,
8685
onScrollBottom,
8786
onCreateOption,
88-
onSearch,
8987
onExceed,
9088

9189
dFormControl,
@@ -94,6 +92,7 @@ export function DSelect<V extends DId, T extends DSelectOption<V>>(props: DSelec
9492
dSize,
9593
onVisibleChange,
9694
onClear,
95+
onSearch,
9796

9897
className,
9998
...restProps
@@ -401,12 +400,6 @@ export function DSelect<V extends DId, T extends DSelectOption<V>>(props: DSelec
401400
dSize={size}
402401
dInputProps={{
403402
'aria-controls': listId,
404-
onChange: (e) => {
405-
const value = e.currentTarget.value;
406-
setSearchValue(value);
407-
408-
onSearch?.(value);
409-
},
410403
onKeyDown: (e) => {
411404
if (visible && !isUndefined(focusOption)) {
412405
switch (e.code) {
@@ -461,6 +454,11 @@ export function DSelect<V extends DId, T extends DSelectOption<V>>(props: DSelec
461454
changeSelect(null);
462455
}
463456
}}
457+
onSearch={(value) => {
458+
onSearch?.(value);
459+
460+
setSearchValue(value);
461+
}}
464462
onVisibleChange={changeVisible}
465463
onFocusVisibleChange={setIsFocusVisible}
466464
>

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9214,7 +9214,7 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.1.0, postcss-value-parser@^
92149214
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
92159215
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==
92169216

9217-
postcss@^8.2.13, postcss@^8.3.11, postcss@^8.3.5, postcss@^8.4.0, postcss@^8.4.7:
9217+
postcss@^8.2.13, postcss@^8.3.5, postcss@^8.4.0, postcss@^8.4.7:
92189218
version "8.4.8"
92199219
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.8.tgz#dad963a76e82c081a0657d3a2f3602ce10c2e032"
92209220
integrity sha512-2tXEqGxrjvAO6U+CJzDL2Fk2kPHTv1jQsYkSoMeOis2SsYaXRO2COxTdQp99cYvif9JTXaAk9lYGc3VhJt7JPQ==
@@ -9223,7 +9223,7 @@ postcss@^8.2.13, postcss@^8.3.11, postcss@^8.3.5, postcss@^8.4.0, postcss@^8.4.7
92239223
picocolors "^1.0.0"
92249224
source-map-js "^1.0.2"
92259225

9226-
postcss@^8.4.14:
9226+
postcss@^8.3.11, postcss@^8.4.14:
92279227
version "8.4.14"
92289228
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.14.tgz#ee9274d5622b4858c1007a74d76e42e56fd21caf"
92299229
integrity sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==

0 commit comments

Comments
 (0)