Skip to content

Conversation

afc163
Copy link
Member

@afc163 afc163 commented Feb 23, 2021

@vercel
Copy link

vercel bot commented Feb 23, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/react-component/dialog/7rtX76vT2chf3Ty5aToTZiXNUioi
✅ Preview: https://dialog-git-fix-afterclose-react-component.vercel.app

@@ -81,7 +81,10 @@ export default function Dialog(props: IDialogChildProps) {
lastOutSideActiveElementRef.current = null;
}

afterClose?.();
// Trigger afterClose only when change visible from true to false
if (animatedVisible) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只有当 visible 从 true 变为 false 时才触发,避免 mount 时直接触发 afterClose。

这里拿不到 prevVisible,有个 animatedVisible 测试起来貌似可用。

@zombieJ@shaodahong 帮忙确认一下。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面 73 行设为 false 了,会出现 true 的情况吗?

@codecov
Copy link

codecov bot commented Feb 23, 2021

Codecov Report

Merging #244 (88add02) into master (cb7c94f) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #244      +/-   ##
==========================================
+ Coverage   98.11%   98.12%   +0.01%     
==========================================
  Files           6        6              
  Lines         159      160       +1     
  Branches       46       47       +1     
==========================================
+ Hits          156      157       +1     
  Misses          2        2              
  Partials        1        1              
Impacted Files Coverage Δ
src/Dialog/index.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb7c94f...6964ccc. Read the comment docs.

Copy link
Member

@shaodahong shaodahong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看了下可以

@kerm1it
Copy link
Member

kerm1it commented Mar 5, 2021

@afc163 这个没问题可以合了。

@zombieJ
Copy link
Member

zombieJ commented Mar 5, 2021

记录一下原因:

rc-motiononVisibleChange 是始终触发以确保有无动画的时机一致性。Dialog 里 animatedVisibletrue 的启动时机一定是受控 visible。消失时机一定是 rc-motion 动画结束。因而 animatedVisiblefalseonVisibleChange 则说明是第一次 mount 且没有动画的情况。

@afc163 afc163 merged commit 119d525 into master Mar 5, 2021
@afc163 afc163 deleted the fix-afterClose branch March 5, 2021 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modal 设置 getContainer 会触发 afterClose 事件。
5 participants