Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Keyboard not showing up on iOS when focus #545

Merged
merged 1 commit into from Sep 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在 IE11 下测试,不加这个 hack,IE 也能触发了。

也就是说完全回到 #513 修改前的状态也能触发 focus 了,见鬼。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先这样吧,遇到反馈再说。

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