Skip to content

Commit 3b21cf2

Browse files
committed
Trigger afterPopupVisibleChange after portal updated
1 parent 4c84908 commit 3b21cf2

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@
6161
"prop-types": "15.x",
6262
"rc-align": "2.x",
6363
"rc-animate": "2.x",
64-
"rc-util": "^4.1.0"
64+
"rc-util": "^4.2.0"
6565
}
6666
}

src/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ const Trigger = createReactClass({
126126
} else {
127127
popupVisible = !!props.defaultPopupVisible;
128128
}
129+
130+
this.prevPopupVisible = popupVisible;
131+
129132
return {
130133
popupVisible,
131134
};
@@ -163,10 +166,10 @@ const Trigger = createReactClass({
163166
};
164167
if (!IS_REACT_16) {
165168
this.renderComponent(null, triggerAfterPopupVisibleChange);
166-
} else {
167-
triggerAfterPopupVisibleChange();
168169
}
169170

171+
this.prevPopupVisible = prevState.popupVisible;
172+
170173
// We must listen to `mousedown`, edge case:
171174
// https://github.com/ant-design/ant-design/issues/5804
172175
// https://github.com/react-component/calendar/issues/250
@@ -313,6 +316,12 @@ const Trigger = createReactClass({
313316
}
314317
},
315318

319+
handlePortalUpdate() {
320+
if (this.prevPopupVisible !== this.state.popupVisible) {
321+
this.props.afterPopupVisibleChange(this.state.popupVisible);
322+
}
323+
},
324+
316325
getPopupDomNode() {
317326
// for test
318327
if (this._component && this._component.getPopupDomNode) {
@@ -574,6 +583,7 @@ const Trigger = createReactClass({
574583
<Portal
575584
key="portal"
576585
getContainer={this.getContainer}
586+
didUpdate={this.handlePortalUpdate}
577587
>
578588
{this.getComponent()}
579589
</Portal>

0 commit comments

Comments
 (0)