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

useClickOutside multiple nodes documentation shows broken 'null' argument #3119

Closed
charliequin opened this issue Dec 5, 2022 · 1 comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@charliequin
Copy link

Link to the page where something nasty is located

https://mantine.dev/hooks/use-click-outside/#multiple-nodes

Exact quote of what is wrong

The following hook is documented as taking two null values as argument for the nodes parameter like so

const [dropdown, setDropdown] = useState(null);
const [control, setControl] = useState(null);

useClickOutside(() => console.log('outside'), null, [control, dropdown]);

but throws a TS due to being typed as an HTMLElement

function useClickOutside<T extends HTMLElement = any>(
  handler: () => void,
  events?: string[] | null,
  nodes?: HTMLElement[]
): React.MutableRefObject<T>;

The documentation should reflect this or be typed to accept null as an argument by default until a ref to an element has been supplied.

Are you willing to create pull request with the fix?

Yes

@rtivital rtivital added Fixed patch Completed issues that will be published with next patch (1.0.X) and removed review required labels Dec 6, 2022
rtivital added a commit that referenced this issue Dec 12, 2022
@rtivital
Copy link
Member

Fixed in 5.9.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

2 participants