Skip to content

Commit 5b9d20d

Browse files
popper position should be updated when
hiddenTabIDs is changed
1 parent 717e167 commit 5b9d20d

File tree

1 file changed

+10
-4
lines changed
  • src/plugins/moreButtonPlugin/button/popper

1 file changed

+10
-4
lines changed

src/plugins/moreButtonPlugin/button/popper/popper.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
import React, { useLayoutEffect, useRef } from 'react';
1+
import React, {useLayoutEffect, useRef} from 'react';
22
import PropTypes from 'prop-types';
33
export default function Popper(getDeps, props) {
4-
const { createPopper, getPopperMaxHeight, getClassName, clk } = getDeps();
5-
const { TabsComponent, instance, hiddenTabIDs, btnRef } = props;
4+
const {createPopper, getPopperMaxHeight, getClassName, clk} = getDeps();
5+
const {TabsComponent, instance, hiddenTabIDs, btnRef} = props;
66
const popperRef = useRef();
7+
const ref = useRef();
8+
ref.current = ref.current || {};
79
useLayoutEffect(() => {
810
popperRef.current.style.maxHeight = getPopperMaxHeight(btnRef.current, 15) + 'px';
911
const popperIns = createPopper(btnRef.current, popperRef.current);
12+
ref.current.popperIns = popperIns;
1013
return () => {
1114
popperIns.destroy();
1215
};
1316
}, []);
14-
const { selectedTabID } = instance.getData();
17+
useLayoutEffect(() => {
18+
ref.current.popperIns.update();
19+
}, [hiddenTabIDs]);
20+
const {selectedTabID} = instance.getData();
1521
const openedTabIDs = hiddenTabIDs ? hiddenTabIDs.split(',') : [];
1622
return (
1723
<>

0 commit comments

Comments
 (0)