Skip to content

Commit 4709d00

Browse files
author
Viktor_the_great
committed
Revert "pass whole popperConfig to PopperJS (react-bootstrap#748)"
This reverts commit 453ff44
1 parent 892401c commit 4709d00

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
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/Overlay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const Overlay = React.forwardRef((props, outerRef) => {
3333
const { modifiers = {} } = popperConfig;
3434

3535
const { styles, arrowStyles, ...popper } = usePopper(target, rootElement, {
36-
popperConfig,
36+
...popperConfig,
3737
placement: placement || 'bottom',
3838
enableEvents: props.show,
3939
modifiers: {

src/usePopper.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,22 @@ 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 {Object} options.popperConfig Popper.js options (except modifiers, placement, positionFixed)
25+
* @param {Function} options.onCreate called when the popper is created
26+
* @param {Function} options.onUpdate called when the popper is updated
2627
*/
2728
export default function usePopper(
2829
referenceElement,
2930
popperElement,
30-
{
31+
options = {},
32+
) {
33+
const {
3134
enabled = true,
3235
placement = 'bottom',
3336
positionFixed = false,
3437
eventsEnabled = true,
3538
modifiers = {},
36-
popperConfig = {},
37-
} = {},
38-
) {
39+
} = options;
40+
3941
const popperInstanceRef = useRef();
4042

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

8587
popperInstanceRef.current = new PopperJS(referenceElement, popperElement, {
86-
...popperConfig,
88+
...options,
8789
placement,
8890
positionFixed,
8991
modifiers: {

0 commit comments

Comments
 (0)