Skip to content

fix: vertical animation not being affected by inline - #578

Merged
MadCcc merged 4 commits into
react-component:masterfrom
JarvisArt:fix-vertical
Jan 17, 2023
Merged

fix: vertical animation not being affected by inline#578
MadCcc merged 4 commits into
react-component:masterfrom
JarvisArt:fix-vertical

Conversation

@JarvisArt

Copy link
Copy Markdown
Contributor

这是个祖传bug,一两年前就有这个问题
ant-design/ant-design#39283

mode 为 vertical 和 horizontal 才需要用到 PopupTrigger,
快速切换时 inline 的 Motion 会影响到 vertical 的结束动画。

@codecov

codecovBot commented Dec 30, 2022

Copy link
Copy Markdown

Codecov Report

Merging #578 (7f557dc) into master (4bf8568) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 7f557dc differs from pull request most recent head 2e8843c. Consider uploading reports for the commit 2e8843c to get more accurate results

@@ Coverage Diff @@## master #578 +/- ##
=======================================
Coverage 99.85% 99.85% =======================================
Files 26 26 Lines 707 710 +3 Branches 193 194 +1 =======================================
+ Hits 706 709 +3 
Misses 1 1 
Impacted FilesCoverage Δ
src/SubMenu/PopupTrigger.tsx100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@afc163

Copy link
Copy Markdown
Member

好写 test case 么

@JarvisArt

Copy link
Copy Markdown
ContributorAuthor

好写 test case 么

我看看

@JarvisArt

Copy link
Copy Markdown
ContributorAuthor

如果没问题发个 minor 版本保险点

Comment threadsrc/SubMenu/PopupTrigger.tsx Outdated
const targetMotion = getMotion(mode, motion, defaultMotions);
const [innerMotion, setInnerMotion] = React.useState(targetMotion);

React.useEffect(() => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Menu 这块越来越复杂了,v4 改由数据驱动后,重构这部分逻辑的活需要提上日程 @MadCcc

@zombieJ
zombieJ requested a review from MadCccJanuary 3, 2023 08:08
Comment threadsrc/SubMenu/PopupTrigger.tsx Outdated
* When collapsed is unfolded, the inline animation will destroy the vertical animation.
*/
if (mode !== 'inline') {
setInnerMotion(targetMotion);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这个不是和默认值一样嘛

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

这里的处理主要是 modeinline 的时候,不改变上一次 modeMotioninlineMotion 会破坏其他 mode 的隐藏动画
image

@JarvisArtJarvisArtJan 17, 2023

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

比如一个弹窗在鼠标失去焦点后 other 有个动画 300ms 后会让这个弹窗隐藏,但是如果300ms内快速切换成 inline mode 的动画,那么 other 的隐藏动画就会失效

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

懂了

@MadCccMadCccJan 17, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

那是不是用个 ref 就好了,不需要副作用?这样少一次渲染

constmotionRef=useRef(targetMotion);if(mode!=='inline'){motionRef.current=targetMotion;}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

那是不是用个 ref 就好了,不需要副作用?这样少一次渲染

确实~ 等会我试下

@MadCcc
MadCcc merged commit f9e8c6b into react-component:masterJan 17, 2023
Sign up for freeto 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.

4 participants

@JarvisArt@afc163@zombieJ@MadCcc