Skip to content
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

Merged
merged 5 commits into from
Feb 6, 2023

Conversation

RedJue
Copy link
Contributor

@RedJue RedJue commented Feb 3, 2023

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 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

Language Changelog
🇺🇸 English Fix segmented not work in RTL mode
🇨🇳 Chinese 修复 Segmented 组件在RTL模式下不按预期工作的问题

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@MadCcc MadCcc requested a review from vagusX February 3, 2023 10:07
right:
targetElement.parentElement?.clientWidth! -
targetElement.clientWidth -
targetElement.offsetLeft,
Copy link
Member

Choose a reason for hiding this comment

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

感觉改多了,是不是把 left 换成 insetInlineStart 就够了?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好像不行,试了下 offsetLeft 偏移量是受 RTL 模式影响的,会导致计算结果不按预期。

Copy link
Member

Choose a reason for hiding this comment

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

这里的 thumb 滑块使用 translateX 做的偏移,不是用 left/insetInlineStart 实现的

Copy link
Contributor Author

Choose a reason for hiding this comment

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

再跑下ci,之前的 test case 有问题 修复了一下。

@RedJue RedJue requested review from afc163 and removed request for vagusX February 4, 2023 13:55
@vagusX vagusX self-requested a review February 4, 2023 14:24
@codecov
Copy link

codecov bot commented Feb 6, 2023

Codecov Report

Merging #167 (5d7fe20) into master (cb02dd6) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            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              
Impacted Files Coverage Δ
src/index.tsx 98.27% <ø> (ø)
src/MotionThumb.tsx 100.00% <100.00%> (ø)

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

Comment on lines +9 to +29
<button
onClick={() => {
setDirection('rtl');
}}
style={{
padding: '0 8px',
marginRight: 8,
}}
>
rtl
</button>
<button
onClick={() => {
setDirection('ltr');
}}
style={{
padding: '0 8px',
}}
>
ltr
</button>
Copy link

Choose a reason for hiding this comment

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

写成 toggleButtong 是不是更简洁一些

Copy link
Contributor Author

Choose a reason for hiding this comment

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

主要为了显示清楚一点,所以分成了两个 buttondemo 上看上去更直观一点,个人感觉。

@vagusX vagusX changed the title Fix/rtl switch fix: rtl switch issue https://github.com/ant-design/ant-design/issues/40128 Feb 6, 2023
@vagusX vagusX merged commit 56975dc into react-component:master Feb 6, 2023
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.

Segmented not work in RTL mode
4 participants