Andarist / Andarist/use-onclickoutside

Don't trigger when scrolling down on mobile?

未關閉
#11 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
496
分支
27
PR 合併指標
30 天內沒有已合併 PR

描述

Is there a way to make this **not** trigger when scrolling down on a mobile device?

Repro:
1. Go to https://beta.dnstools.ws/ on a mobile device
2. Select the "Ping" option
3. Open the "locations" dropdown
4. Scroll down by tapping and dragging on the body (not the dropdown list)

The dropdown list closes, but it should remain open.

Here's the code I'm using:
```js
import React, {useRef, useState} from 'react';
import useOnClickOutside from 'use-onclickoutside';

type Props = {
children: React.ReactNode;
id: string;
label: string;
};

export default function DropdownButton(props: Props) {
const rootRef = useRef(null);
const [isOpen, setIsOpen] = useState(false);
useOnClickOutside(rootRef, () => setIsOpen(false));

return (


setIsOpen(value => !value)}
type="button"
data-toggle="dropdown"
aria-haspopup={true}
aria-expanded={isOpen}>
{props.label}


{props.children}


);
}

```

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。