Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/Selector/index.tsx
Original file line number Diff line number Diff line change
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