Skip to content

Commit

Permalink
fix: 解决支付宝小程序Picker中导致 targetId not match (#1241)
Browse files Browse the repository at this point in the history
  • Loading branch information
rayhomie authored Jul 11, 2024
1 parent d2396bd commit 9379530
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion compiled/alipay/src/Popup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ Component(
const enableAnimation = animation && duration > 0;
if (prevProps.visible !== visible) {
if (enableAnimation && !visible) {
this.setData({ closing: true });
setTimeout(() => {
// 这里需要用setTimeout包一下,解决支付宝小程序Picker中导致 targetId not match
this.setData({ closing: true });
});
}
if (!enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
Expand Down
5 changes: 4 additions & 1 deletion src/Popup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ Component(
const enableAnimation = animation && duration > 0;
if (prevProps.visible !== visible) {
if (enableAnimation && !visible) {
this.setData({ closing: true });
setTimeout(() => {
// 这里需要用setTimeout包一下,解决支付宝小程序Picker中导致 targetId not match
this.setData({ closing: true });
});
}
if (!enableAnimation) {
triggerEventOnly(this, visible ? 'afterShow' : 'afterClose');
Expand Down
2 changes: 2 additions & 0 deletions tests/alipay/Popup/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Popup', () => {
instance.setProps({
visible: false,
});
await sleep(10);
expect(instance.getData().closing).toBe(true);
instance.callMethod('onAnimationEnd');
await sleep(20);
Expand All @@ -42,6 +43,7 @@ describe('Popup', () => {
instance.setProps({
visible: false,
});
await sleep(10);
expect(instance.getData().closing).toBe(true);
instance.callMethod('onTapMask');
expect(onClose.mock.calls.length).toBe(1);
Expand Down

0 comments on commit 9379530

Please sign in to comment.