Skip to content

Commit

Permalink
pass whole popperConfig to PopperJS (react-bootstrap#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor_the_great committed Dec 9, 2019
1 parent 3db0db2 commit 453ff44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/DropdownMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function useDropdownMenu(options = {}) {
else if (drop === 'left') placement = alignEnd ? 'left-end' : 'left-start';

const popper = usePopper(toggleElement, menuElement, {
...popperConfig,
placement,
enabled: !!(shouldUsePopper && show),
eventsEnabled: !!show,
Expand Down
11 changes: 8 additions & 3 deletions src/usePopper.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@ 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
*/
export default function usePopper(
referenceElement,
popperElement,
{
options = {},
) {
const {
enabled = true,
placement = 'bottom',
positionFixed = false,
eventsEnabled = true,
modifiers = {},
} = {},
) {
} = options;

const popperInstanceRef = useRef();

const hasArrow = !!(modifiers.arrow && modifiers.arrow.element);
Expand Down Expand Up @@ -81,6 +85,7 @@ export default function usePopper(
};

popperInstanceRef.current = new PopperJS(referenceElement, popperElement, {
...options,
placement,
positionFixed,
modifiers: {
Expand Down

0 comments on commit 453ff44

Please sign in to comment.