Skip to content

Commit ff55f9a

Browse files
committed
chore: fix ref
1 parent 7e86869 commit ff55f9a

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

src/BaseSelect/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
347347
// ============================== Refs ==============================
348348
const containerRef = React.useRef<SelectInputRef>(null);
349349
const triggerRef = React.useRef<RefTriggerProps>(null);
350-
const selectorRef = React.useRef<RefSelectorProps>(null);
350+
// const selectorRef = React.useRef<RefSelectorProps>(null);
351351
const listRef = React.useRef<RefOptionListProps>(null);
352352
// const blurRef = React.useRef<boolean>(false);
353353
const customDomRef = React.useRef<HTMLElement>(null);
@@ -360,11 +360,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
360360
focus: containerRef.current?.focus,
361361
blur: containerRef.current?.blur,
362362
scrollTo: (arg) => listRef.current?.scrollTo(arg),
363-
nativeElement:
364-
// containerRef.current ||
365-
// selectorRef.current?.nativeElement ||
366-
// (getDOM(customDomRef.current) as HTMLElement),
367-
selectorRef.current?.nativeElement,
363+
nativeElement: getDOM(containerRef.current) as HTMLElement,
368364
}));
369365

370366
// =========================== Components ===========================

src/SelectInput/Content/SingleContent.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ const SingleContent = React.forwardRef<HTMLInputElement, SharedContentProps>(
2626
return activeValue;
2727
}
2828

29-
if (combobox) {
30-
return searchValue;
31-
}
32-
3329
return showSearch ? searchValue : '';
3430
}, [combobox, activeValue, inputChanged, triggerOpen, searchValue, showSearch]);
3531

src/SelectInput/index.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { isValidateOpenKey } from '../utils/keyUtil';
1010
import clsx from 'clsx';
1111
import type { ComponentsConfig } from '../hooks/useComponents';
1212
import { getDOM } from '@rc-component/util/lib/Dom/findDOMNode';
13+
import { composeRef } from '@rc-component/util/lib/ref';
1314

1415
export interface SelectInputRef {
1516
focus: (options?: FocusOptions) => void;
@@ -153,9 +154,8 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
153154
);
154155

155156
// ====================== Refs ======================
156-
React.useImperativeHandle(
157-
ref,
158-
() => ({
157+
React.useImperativeHandle(ref, () => {
158+
return {
159159
focus: (options?: FocusOptions) => {
160160
// Focus the inner input if available, otherwise fall back to root div.
161161
(inputRef.current || rootRef.current).focus?.(options);
@@ -164,9 +164,8 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
164164
(inputRef.current || rootRef.current).blur?.();
165165
},
166166
nativeElement: rootRef.current,
167-
}),
168-
[],
169-
);
167+
};
168+
});
170169

171170
// ====================== Open ======================
172171
const onInternalMouseDown: SelectInputProps['onMouseDown'] = useEvent((event) => {
@@ -231,7 +230,7 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
231230
sharedProps.onBlur(e);
232231
oriProps.onBlur?.(e);
233232
},
234-
ref: rootRef,
233+
ref: composeRef((RootComponent as any).ref, rootRef),
235234
});
236235
}
237236
return <RootComponent {...sharedProps} ref={rootRef} />;

src/hooks/useSearchConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export default function useSearchConfig(
2929

3030
return [
3131
isObject ||
32-
(!showSearch && mode === 'tags') ||
32+
mode === 'combobox' ||
33+
mode === 'tags' ||
3334
(mode === 'multiple' && showSearch === undefined)
3435
? true
3536
: showSearch,

0 commit comments

Comments
 (0)