New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Affix shake when switching from hide to show #38410
Conversation
let affixInstance: InternalAffixClass | null = null;
render(
<AffixMounter
getInstance={inst => {
affixInstance = inst;
}}
offsetBottom={0}
/>,
);
await waitFakeTimer();
await movePlaceholder(300);
console.log(affixInstance!.state.affixStyle); // { position: 'fixed', bottom: 668, width: undefined, height: undefined } hi,我想写一个测试用例,想对比滚动前后 affixStyle 的变化,但是发现 width 和 height 都是 undefined,能指导下我吗? |
jsdom 里元素尺寸和位置都是 0,需要对相关 dom 操作方法做 mock:https://github.com/ant-design/ant-design/blob/master/components/affix/__tests__/Affix.test.tsx#L75-L81 |
Codecov ReportBase: 100.00% // Head: 100.00% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #38410 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 446 446
Lines 8304 8310 +6
Branches 2526 2528 +2
=========================================
+ Hits 8304 8310 +6
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
done |
* fix: do not measure when Affix is hidden * feat: add test
* fix: do not measure when Affix is hidden * feat: add test
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
fix: #37970
💡 Background and solution
📝 Changelog
☑️ Self-Check before Merge