Skip to content

Commit

Permalink
fix: Keyboard not showing up on iOS when focus
Browse files Browse the repository at this point in the history
  • Loading branch information
kerm1it committed Sep 15, 2020
1 parent 4e1e69d commit c1defbd
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/Selector/index.tsx
Expand Up @@ -197,12 +197,8 @@ const Selector: React.RefForwardingComponent<RefSelectorProps, SelectorProps> =
pastedTextRef.current = value;
};

const onMouseDown: React.MouseEventHandler<HTMLElement> = 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) {
Expand All @@ -213,6 +209,13 @@ const Selector: React.RefForwardingComponent<RefSelectorProps, SelectorProps> =
inputRef.current.focus();
}
}
};

const onMouseDown: React.MouseEventHandler<HTMLElement> = event => {
const inputMouseDown = getInputMouseDown();
if (event.target !== inputRef.current && !inputMouseDown) {
event.preventDefault();
}

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

return (
<div ref={domRef} className={`${prefixCls}-selector`} onMouseDown={onMouseDown}>
<div
ref={domRef}
className={`${prefixCls}-selector`}
onClick={onClick}
onMouseDown={onMouseDown}
>
{selectNode}
</div>
);
Expand Down

0 comments on commit c1defbd

Please sign in to comment.