From e90b0595578c099841c4312b164a517db50a197b Mon Sep 17 00:00:00 2001 From: Kermit Xuan Date: Wed, 16 Sep 2020 14:18:53 +0800 Subject: [PATCH] fix: Keyboard not showing up on iOS when focus (#545) --- src/Selector/index.tsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Selector/index.tsx b/src/Selector/index.tsx index f001c2614..f9fb9a9f1 100644 --- a/src/Selector/index.tsx +++ b/src/Selector/index.tsx @@ -197,12 +197,8 @@ const Selector: React.RefForwardingComponent = pastedTextRef.current = value; }; - const onMouseDown: React.MouseEventHandler = event => { - const inputMouseDown = getInputMouseDown(); - if (event.target !== inputRef.current) { - if (!inputMouseDown) { - event.preventDefault(); - } + const onClick = ({ target }) => { + if (target !== inputRef.current) { // Should focus input if click the selector const isIE = (document.body.style as any).msTouchAction !== undefined; if (isIE) { @@ -213,6 +209,13 @@ const Selector: React.RefForwardingComponent = inputRef.current.focus(); } } + }; + + const onMouseDown: React.MouseEventHandler = event => { + const inputMouseDown = getInputMouseDown(); + if (event.target !== inputRef.current && !inputMouseDown) { + event.preventDefault(); + } if ((mode !== 'combobox' && (!showSearch || !inputMouseDown)) || !open) { if (open) { @@ -240,7 +243,12 @@ const Selector: React.RefForwardingComponent = ); return ( -
+
{selectNode}
);