Skip to content

Commit

Permalink
depend on boolean for call
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnC-80 committed Feb 21, 2025
1 parent b903d62 commit a2262c8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/DropdownMenu/DropdownMenu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { cloneElement, useRef } from 'react';
import React, { cloneElement, useRef, useCallback } from 'react';
import isBoolean from 'lodash/isBoolean';
import noop from 'lodash/noop';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -40,7 +40,8 @@ const DropdownMenu = ({ overrideStyle = {}, ...rest }) => {
} = props;

const ref = useRef(null);
useClickOutside(ref, open ? onToggle : noop);
const handleOutsideClick = useCallback((e, outside) => outside && onToggle(), [onToggle]);
useClickOutside(ref, open ? handleOutsideClick : noop);

const renderChildren = () => {
// don't pass along props that we didn't receive. if the
Expand Down

0 comments on commit a2262c8

Please sign in to comment.