diff --git a/src/DropdownMenu.js b/src/DropdownMenu.js index 1cf42efb..cc79f177 100644 --- a/src/DropdownMenu.js +++ b/src/DropdownMenu.js @@ -40,7 +40,7 @@ export function useDropdownMenu(options = {}) { else if (drop === 'left') placement = alignEnd ? 'left-end' : 'left-start'; const popper = usePopper(toggleElement, menuElement, { - ...popperConfig, + popperConfig, placement, enabled: !!(shouldUsePopper && show), eventsEnabled: !!show, diff --git a/src/usePopper.js b/src/usePopper.js index c67fe2d7..24bb8725 100644 --- a/src/usePopper.js +++ b/src/usePopper.js @@ -22,22 +22,20 @@ const initialArrowStyles = {}; * @param {String} options.placement The popper element placement relative to the reference element * @param {Boolean} options.positionFixed use fixed positioning * @param {Boolean} options.eventsEnabled have Popper listen on window resize events to reposition the element - * @param {Function} options.onCreate called when the popper is created - * @param {Function} options.onUpdate called when the popper is updated + * @param {Object} options.popperConfig Popper.js options (except modifiers, placement, positionFixed) */ export default function usePopper( referenceElement, popperElement, - options = {}, -) { - const { + { enabled = true, placement = 'bottom', positionFixed = false, eventsEnabled = true, modifiers = {}, - } = options; - + popperConfig = {}, + } = {}, +) { const popperInstanceRef = useRef(); const hasArrow = !!(modifiers.arrow && modifiers.arrow.element); @@ -85,7 +83,7 @@ export default function usePopper( }; popperInstanceRef.current = new PopperJS(referenceElement, popperElement, { - ...options, + ...popperConfig, placement, positionFixed, modifiers: {