Skip to content

Commit a0ecb67

Browse files
author
Viktor_the_great
committed
pass whole popperConfig to PopperJS (react-bootstrap#748)
* use options.popperConfig to initiate PopperJS
1 parent 453ff44 commit a0ecb67

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/DropdownMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function useDropdownMenu(options = {}) {
4040
else if (drop === 'left') placement = alignEnd ? 'left-end' : 'left-start';
4141

4242
const popper = usePopper(toggleElement, menuElement, {
43-
...popperConfig,
43+
popperConfig,
4444
placement,
4545
enabled: !!(shouldUsePopper && show),
4646
eventsEnabled: !!show,

src/usePopper.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,20 @@ const initialArrowStyles = {};
2222
* @param {String} options.placement The popper element placement relative to the reference element
2323
* @param {Boolean} options.positionFixed use fixed positioning
2424
* @param {Boolean} options.eventsEnabled have Popper listen on window resize events to reposition the element
25-
* @param {Function} options.onCreate called when the popper is created
26-
* @param {Function} options.onUpdate called when the popper is updated
25+
* @param {Object} options.popperConfig Popper.js options (except modifiers, placement, positionFixed)
2726
*/
2827
export default function usePopper(
2928
referenceElement,
3029
popperElement,
31-
options = {},
32-
) {
33-
const {
30+
{
3431
enabled = true,
3532
placement = 'bottom',
3633
positionFixed = false,
3734
eventsEnabled = true,
3835
modifiers = {},
39-
} = options;
40-
36+
popperConfig = {},
37+
} = {},
38+
) {
4139
const popperInstanceRef = useRef();
4240

4341
const hasArrow = !!(modifiers.arrow && modifiers.arrow.element);
@@ -85,7 +83,7 @@ export default function usePopper(
8583
};
8684

8785
popperInstanceRef.current = new PopperJS(referenceElement, popperElement, {
88-
...options,
86+
...popperConfig,
8987
placement,
9088
positionFixed,
9189
modifiers: {

0 commit comments

Comments
 (0)