-
Notifications
You must be signed in to change notification settings - Fork 20
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: rtl switch issue https://github.com/ant-design/ant-design/issues/40128 #167
Conversation
right: | ||
targetElement.parentElement?.clientWidth! - | ||
targetElement.clientWidth - | ||
targetElement.offsetLeft, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉改多了,是不是把 left 换成 insetInlineStart 就够了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好像不行,试了下 offsetLeft
偏移量是受 RTL
模式影响的,会导致计算结果不按预期。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 thumb 滑块使用 translateX 做的偏移,不是用 left/insetInlineStart 实现的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
再跑下ci,之前的 test case 有问题 修复了一下。
Codecov Report
@@ Coverage Diff @@
## master #167 +/- ##
==========================================
+ Coverage 99.11% 99.15% +0.04%
==========================================
Files 2 2
Lines 113 119 +6
Branches 29 31 +2
==========================================
+ Hits 112 118 +6
Misses 1 1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
<button | ||
onClick={() => { | ||
setDirection('rtl'); | ||
}} | ||
style={{ | ||
padding: '0 8px', | ||
marginRight: 8, | ||
}} | ||
> | ||
rtl | ||
</button> | ||
<button | ||
onClick={() => { | ||
setDirection('ltr'); | ||
}} | ||
style={{ | ||
padding: '0 8px', | ||
}} | ||
> | ||
ltr | ||
</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
写成 toggleButtong 是不是更简洁一些
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
主要为了显示清楚一点,所以分成了两个 button
,demo
上看上去更直观一点,个人感觉。
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
fix #40128
💡 Background and solution
Causes of the problem
Because of the display of rtl, there is a problem with the displacement of the calculation logic.
Solution
Fixed displacement under rtl mode.
📝 Changelog
☑️ Self-Check before Merge