Skip to content

Commit e90b059

Browse files
authored
fix: Keyboard not showing up on iOS when focus (#545)
1 parent 4e1e69d commit e90b059

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/Selector/index.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,8 @@ const Selector: React.RefForwardingComponent<RefSelectorProps, SelectorProps> =
197197
pastedTextRef.current = value;
198198
};
199199

200-
const onMouseDown: React.MouseEventHandler<HTMLElement> = event => {
201-
const inputMouseDown = getInputMouseDown();
202-
if (event.target !== inputRef.current) {
203-
if (!inputMouseDown) {
204-
event.preventDefault();
205-
}
200+
const onClick = ({ target }) => {
201+
if (target !== inputRef.current) {
206202
// Should focus input if click the selector
207203
const isIE = (document.body.style as any).msTouchAction !== undefined;
208204
if (isIE) {
@@ -213,6 +209,13 @@ const Selector: React.RefForwardingComponent<RefSelectorProps, SelectorProps> =
213209
inputRef.current.focus();
214210
}
215211
}
212+
};
213+
214+
const onMouseDown: React.MouseEventHandler<HTMLElement> = event => {
215+
const inputMouseDown = getInputMouseDown();
216+
if (event.target !== inputRef.current && !inputMouseDown) {
217+
event.preventDefault();
218+
}
216219

217220
if ((mode !== 'combobox' && (!showSearch || !inputMouseDown)) || !open) {
218221
if (open) {
@@ -240,7 +243,12 @@ const Selector: React.RefForwardingComponent<RefSelectorProps, SelectorProps> =
240243
);
241244

242245
return (
243-
<div ref={domRef} className={`${prefixCls}-selector`} onMouseDown={onMouseDown}>
246+
<div
247+
ref={domRef}
248+
className={`${prefixCls}-selector`}
249+
onClick={onClick}
250+
onMouseDown={onMouseDown}
251+
>
244252
{selectNode}
245253
</div>
246254
);

0 commit comments

Comments
 (0)