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: add root element for SingleSelector to make layout easier #1076

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

guoyunhe
Copy link
Contributor

@guoyunhe guoyunhe commented Oct 11, 2024

经过试验在 Ant Design 调整 prefix 的布局十分困难,因此需要在 SingleSelector 增加一个 wrapper 元素,来限制布局。

Summary by CodeRabbit

  • 新功能

    • 引入了新的搜索输入样式,移除了边框并应用半透明红色背景。
    • 增强了下拉菜单的动画效果,包括滑入和滑出状态的平滑过渡。
  • 样式更新

    • 更新了多个选择器和单个选择器的样式,以改善组件的布局和外观。

Copy link

vercel bot commented Oct 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
select ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 15, 2024 6:01am

Copy link

codecov bot commented Oct 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.24%. Comparing base (fb2a981) to head (add12a0).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1076   +/-   ##
=======================================
  Coverage   98.23%   98.24%           
=======================================
  Files          39       39           
  Lines        1474     1482    +8     
  Branches      439      446    +7     
=======================================
+ Hits         1448     1456    +8     
  Misses         26       26           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -77,7 +77,7 @@ const SingleSelector: React.FC<SelectorProps> = (props) => {
}, [item, hasTextInput, placeholder, prefixCls]);

return (
<>
<span className={`${prefixCls}-selection-wrap`}>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<span className={`${prefixCls}-selection-wrap`}>
<span className={`${prefixCls}-selection`}>

不需要加 wrap

Copy link
Member

@zombieJ zombieJ Oct 14, 2024

Choose a reason for hiding this comment

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

placeholder 特殊标记使用:classNames(xx-selection, xxx-selection-placeholder)

看起来是额外多一层?结构保持一致把,Single 和 Multiple 要加就一起加了:
https://github.com/react-component/select/blob/master/src/Selector/SingleSelector.tsx#L80
https://github.com/react-component/select/blob/master/src/Selector/MultipleSelector.tsx#L245

@guoyunhe guoyunhe force-pushed the single-selector-root branch from 4b55511 to add12a0 Compare October 15, 2024 06:00
Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Walkthrough

此次变更涉及对与 rc-select 功能相关的样式和组件进行多项修改。在 assets/index.less 中,新增了 .search-input-without-border 类以去除搜索输入框的边框,并应用半透明红色背景。同时,更新了 .rc-select-single.rc-select-multiple 类以调整其内部结构和样式。此外,增加了下拉菜单的动画效果,增强了用户体验。在 src/Selector/MultipleSelector.tsxsrc/Selector/SingleSelector.tsx 中,外层 JSX 片段被替换为 <span> 元素,以影响组件的样式和布局。

Changes

文件路径 变更摘要
assets/index.less 新增类 .search-input-without-border;新增嵌套类 .rc-select-selection-wrap;更新 .rc-select-selection-search-input 的样式;更新动画关键帧。
src/Selector/MultipleSelector.tsx, src/Selector/SingleSelector.tsx 外层 JSX 片段替换为 <span> 元素。

Suggested reviewers

  • zombieJ

Poem

在田野间,我跳跃欢快,
新样式如花,绽放无碍。
组件更新,布局新奇,
小兔子乐,舞动不息! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e08455c and add12a0.

⛔ Files ignored due to path filters (5)
  • tests/__snapshots__/Combobox.test.tsx.snap is excluded by !**/*.snap
  • tests/__snapshots__/Multiple.test.tsx.snap is excluded by !**/*.snap
  • tests/__snapshots__/Select.test.tsx.snap is excluded by !**/*.snap
  • tests/__snapshots__/Tags.test.tsx.snap is excluded by !**/*.snap
  • tests/__snapshots__/ssr.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • assets/index.less (1 hunks)
  • src/Selector/MultipleSelector.tsx (1 hunks)
  • src/Selector/SingleSelector.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/Selector/MultipleSelector.tsx
🧰 Additional context used
🔇 Additional comments (3)
src/Selector/SingleSelector.tsx (1)

80-80: 🛠️ Refactor suggestion

考虑调整类名以保持一致性

添加包装元素的变更符合PR的目标,有助于简化布局调整。然而,有以下几点建议:

  1. 根据之前的评论,考虑将类名从 ${prefixCls}-selection-wrap 更改为 ${prefixCls}-selection
  2. 确保 SingleSelector 和 MultipleSelector 组件的结构保持一致。如果在这里添加了额外的包装层,可能需要在 MultipleSelector 中也进行相应的修改。

建议应用以下更改:

-    <span className={`${prefixCls}-selection-wrap`}>
+    <span className={`${prefixCls}-selection`}>

请运行以下脚本来验证 SingleSelector 和 MultipleSelector 的一致性:

Also applies to: 124-124

assets/index.less (2)

Line range hint 1-477: 文件变更总结

这个 LESS 文件的变更聚焦于改善单选择器的布局控制,通过添加新的 .rc-select-selection-wrap 类实现。这个改动与 PR 的目标一致,即通过添加包装元素使布局更容易调整。

整体而言,变更是最小化和集中的,这有利于维护性并降低了产生意外副作用的风险。然而,为确保变更的有效性和一致性,建议:

  1. 在相关的 React 组件文件中验证新增包装元素的使用情况。
  2. 考虑更新组件文档,反映这一新的布局结构。
  3. 如果有单元测试或集成测试,确保更新它们以覆盖这一变更。

73-77: 新增的包装元素有助于布局控制

新增的 .rc-select-selection-wrap 类为单选择器提供了额外的布局控制。这与 PR 的目标一致,即通过添加包装元素使布局更容易调整。

建议:

  1. 考虑为这个新的包装元素添加注释,解释其用途和重要性。
  2. 确保在相应的 React 组件中正确使用了这个新的包装元素。

请运行以下脚本来验证新增的包装元素在 React 组件中的使用:


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

3 participants