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(base-select): [base-select] fix style issues in the old theme #2535

Merged
merged 2 commits into from
Nov 20, 2024

Conversation

kagol
Copy link
Member

@kagol kagol commented Nov 19, 2024

PR

主要修复 base-select 组件在老主题下的以下问题:

  • 多选demo:高度不对,应该是28px,而不是32px -- 解决方案:设置tag的高度,input高度是根据tag高度动态设置的
  • 折叠标签demo:场景1和场景2样式高度不对,展开按钮未居中
  • 尺寸demo:mini尺寸不对 -- mini和small尺寸保持一致,均为24px,再小就没意义了
  • 下拉面板可搜索demo:搜索框前置图标错位
  • 下拉面板插槽demo:场景2选不中

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new option "广州" to the selection list in the base select component.
    • Enhanced multi-select functionality with an isTree property for selected nodes.
  • Bug Fixes

    • Improved handling of user interactions and state management in the base select component.
  • Style

    • Introduced new styles for tag sizes in the base select component, allowing better visual adaptation.
    • Updated dropdown styles for improved layout and presentation during loading and empty states.

@kagol kagol added the bug Something isn't working label Nov 19, 2024
Copy link

coderabbitai bot commented Nov 19, 2024

Walkthrough

The changes in this pull request primarily enhance the functionality and styling of the tiny-base-select and related components. A new option is added to the select options array, and modifications are made to the event handling and data structures associated with multi-select operations. Additionally, updates to styles are made to accommodate different size variations of tags and improve the dropdown's appearance and behavior in various states.

Changes

File Path Change Summary
examples/sites/demos/pc/app/base-select/collapse-tags-composition-api.vue Added a new option { value: '选项6', label: '广州' } to the options array.
examples/sites/demos/pc/app/base-select/slot-panel-composition-api.vue Added isTree property to the object passed to updateSelectedData in the @check event handler for the multi-select scenario.
examples/sites/demos/pc/app/base-select/slot-panel.vue Added isTree: true to objects mapped from checkedNodes in the multi-select scenario's @check event handler.
packages/renderless/src/base-select/index.ts Updated defaultSizeMap structure, added methods for handling tag display and search functionality, and introduced debouncing for query changes.
packages/theme/src/base-select/index.less Added new styles for tag heights based on component size variations.
packages/theme/src/select-dropdown/index.less Introduced new styles for handling empty and loading states in the dropdown, along with modifications to existing styles for search input and layout behavior.

Possibly related PRs

Suggested reviewers

  • zzcr

🐰 "In the garden of options, a new choice blooms,
With tags that fit snug, like soft, cozy rooms.
A tree structure added, for choices to grow,
In a dropdown so lovely, with styles all aglow!
Let's hop to the changes, with joy in our hearts,
For each little update, a fresh start imparts!" 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd8136 and 1f7e188.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/app/base-select/size.spec.ts (1 hunks)

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.

@kagol kagol changed the title fix(base-select): fix style issues in the old theme fix(base-select): [base-select] fix style issues in the old theme Nov 19, 2024
Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (4)
packages/theme/src/base-select/index.less (1)

206-222: LGTM! The tag height definitions follow a clear size progression.

The implementation provides a well-structured set of size variants for tags:

  • Default: 20px
  • Medium: 24px
  • Small/Mini: 16px

This follows common UI component library patterns where medium is larger than default, and small/mini share the same compact size.

Consider documenting these size variants in the component's documentation to help users understand the available options and their visual impact.

packages/renderless/src/base-select/index.ts (3)

Line range hint 2101-2104: Translate code comments to English for consistency

The comments in computedShowTagText are in Chinese. Please translate them to English to maintain code consistency and readability.

Apply the following diff:

-/**
- * 兼容不同主题多选禁用的展示类型
- * default 和 smb 主题,displayOnly 时显示为 tagText,否则为 tag
- * aurora 主题 displayOnly||disabled 时显示为tagText,否则为 tag
- */
+/**
+ * Ensure compatibility of multi-select disabled display types across different themes.
+ * In default and SMB themes, display as `tagText` when in `displayOnly` mode; otherwise, display as `tag`.
+ * In Aurora theme, display as `tagText` when in `displayOnly` or `disabled` mode; otherwise, display as `tag`.
+ */

Line range hint 2107-2110: Translate code comments to English for consistency

The comments in isTagClosable are in Chinese. Please translate them to English to improve code maintainability.

Apply the following diff:

-/**
- * 兼容不同主题多选,tag 在disabled 和 required 时是否显示关闭按钮的区别
- * default 主题 ,禁用显示关闭按钮,required目前和aurora保持一致不显示,待设计图补充时更新
- * aurora 主题,禁用时无禁用效果,required 时不显示关闭按钮
- */
+/**
+ * Handle differences in displaying the close button for tags in multi-select across different themes when disabled or required.
+ * In the default theme, show the close button when disabled. Currently, `required` follows Aurora in not showing the close button; to be updated when design guidelines are provided.
+ * In the Aurora theme, there is no disabled effect when disabled; do not show the close button when `required` is true.
+ */

Line range hint 2130-2133: Translate code comments to English for consistency

The comment above handleDebouncedQueryChange is in Chinese. Please translate it to English to maintain code clarity and readability.

Apply the following diff:

-// 解决无界时,event.target 会变为 wujie_iframe的元素的bug
+// Fix the issue where `event.target` becomes the element of `wujie_iframe` in certain situations
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dcb10aa and 1dd8136.

📒 Files selected for processing (6)
  • examples/sites/demos/pc/app/base-select/collapse-tags-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/base-select/slot-panel-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/base-select/slot-panel.vue (1 hunks)
  • packages/renderless/src/base-select/index.ts (1 hunks)
  • packages/theme/src/base-select/index.less (1 hunks)
  • packages/theme/src/select-dropdown/index.less (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/theme/src/select-dropdown/index.less
🔇 Additional comments (8)
examples/sites/demos/pc/app/base-select/collapse-tags-composition-api.vue (1)

36-37: Verify impact on collapse tag demonstrations

Please verify that adding the new option '广州' doesn't affect the demonstration scenarios, particularly for:

  1. The collapse-tags behavior with showProportion
  2. The hover-expand functionality
  3. The click-expand with maxVisibleRows=2

Consider updating the default values in value1, value2, or value3 to demonstrate the new option if needed.

✅ Verification successful

No impact on collapse tag demonstrations

After analyzing the code, the addition of the '广州' option doesn't affect any of the demonstration scenarios because:

  1. The value1, value2, and value3 default values don't include the new '选项6' option
  2. The demonstrations focus on different collapse behaviors (showProportion, hover-expand, click-expand) which are independent of the specific options
  3. The existing selected values already provide sufficient examples for each collapse behavior:
    • value1 shows basic collapse-tags with 2 items
    • value2 demonstrates hover-expand with 4 items
    • value3 tests click-expand with 5 items and maxVisibleRows=2

No changes to the default values are needed as the current selections effectively demonstrate all features.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other demos or tests that might be affected by this new option
rg -l "选项6.*广州" --type vue

Length of output: 56


Script:

#!/bin/bash
# Search for files containing both '选项6' and '广州' in any order
rg "选项6|广州" -l

# Also get the content of the current file to analyze the demonstration scenarios
cat "examples/sites/demos/pc/app/base-select/collapse-tags-composition-api.vue"

Length of output: 18340

examples/sites/demos/pc/app/base-select/slot-panel-composition-api.vue (1)

43-44: Verify the impact of the isTree property

Let's verify how this property is used in the codebase and ensure it doesn't break existing functionality.

✅ Verification successful

Let me try a different approach to search for the isTree usage.


Let me search for the base-select component implementation to understand how the isTree property is used.


Let me check the tree-select renderless implementation to understand how the isTree property is used.


Based on the code analysis, I can now provide the final response:

The isTree property is safely used and verified

The isTree property is correctly used in the tree-select component to mark tree node selections in the base-select component. This property is essential for:

  1. Distinguishing tree node selections from regular options in the base-select component
  2. Proper handling of tree node data in the selection logic
  3. Consistent behavior with the existing tree-select implementation

The property is used in both the demo examples and the core tree-select component implementation, indicating it's a required part of the component's functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usages of isTree property in the codebase
echo "Searching for isTree property usage in components..."
rg -l "isTree" --type vue --type ts

# Search for base-select component implementations
echo "Searching for base-select implementations..."
rg -l "tiny-base-select" --type vue

# Search for tree-related props or methods in base-select
echo "Searching for tree-related functionality in base-select..."
ast-grep --pattern 'export default {
  $$$
  props: {
    $$$
    isTree: $_
    $$$
  }
  $$$
}'

Length of output: 568


Script:

#!/bin/bash
# Search for isTree property usage without file type restrictions
echo "Searching for isTree property usage..."
rg "isTree" -A 3 -B 3

# Search for base-select implementations
echo "Searching for base-select component references..."
rg "tiny-base-select"

# Look for the component definition file
echo "Looking for base-select component file..."
fd "base-select" --type f

Length of output: 74883


Script:

#!/bin/bash
# Look at the base-select component implementation
echo "Checking base-select component implementation..."
cat packages/vue/src/base-select/src/pc.vue

# Look at the renderless logic
echo "Checking renderless implementation..."
cat packages/renderless/src/base-select/index.ts

# Look at the tree-select component that uses base-select
echo "Checking tree-select component..."
cat packages/vue/src/tree-select/src/pc.vue

Length of output: 82215


Script:

#!/bin/bash
# Check tree-select renderless implementation
echo "Checking tree-select renderless implementation..."
cat packages/renderless/src/tree-select/index.ts

# Check if there are any other relevant files
echo "Looking for other relevant files..."
rg "isTree.*true" -A 2 -B 2

Length of output: 2961

examples/sites/demos/pc/app/base-select/slot-panel.vue (1)

43-44: Verify the impact of isTree property

The addition of isTree: true might affect how selected nodes are processed in the parent components.

Let's verify how this property is used:

✅ Verification successful

The isTree: true property is used correctly and safely

Based on the codebase analysis, the isTree property is a standard flag used throughout the codebase to handle tree-specific rendering and data processing in select components. In the context of slot-panel.vue, it's used to properly identify tree-based selections, which is consistent with the implementation in:

  • packages/renderless/src/select/index.ts - Used for determining rendering behavior and option processing
  • packages/renderless/src/base-select/index.ts - Used for selection state management
  • Other tree-select related components showing the same pattern
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of isTree property in the codebase
rg "isTree" --type vue --type ts --type js -B 2 -A 2

Length of output: 80


Script:

#!/bin/bash
# Search for usage of isTree property in all files
rg "isTree" -B 2 -A 2

Length of output: 15079

packages/theme/src/base-select/index.less (1)

206-222: Verify integration with existing size-specific styles.

The new tag height definitions coexist with other size-specific styles in the file. Please verify that these heights work correctly with:

  1. The existing tag margins (line 147)
  2. The hover-expand state padding adjustments for small/mini sizes (lines 328-340)
✅ Verification successful

Based on the search results, I can now verify the integration of the new tag height definitions with existing styles. Let me analyze the findings:

No conflicts found with existing tag height definitions

  1. The new tag heights (20px, 24px, 16px) are consistent with the component's size system and don't conflict with existing styles.
  2. The tag margins (line 147) are not impacted since they work independently of the height property.
  3. The hover-expand state padding adjustments (lines 328-340) operate on padding rather than height, allowing both properties to work together without interference.

The changes are safe and properly integrated with the existing styling system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other size-related styles that might interact with these new heights
rg -l "(?:small|medium|mini)" --type less

# Look for any existing height definitions that might conflict
rg "height:" --type less

Length of output: 150787

packages/renderless/src/base-select/index.ts (4)

1605-1605: Changes to defaultSizeMap are acceptable

The updates to defaultSizeMap reflect the intended design specifications.


Line range hint 2120-2129: Function clearNoMatchValue correctly handles unmatched values

The implementation of clearNoMatchValue appropriately updates modelValue when clearNoMatchValue prop is set and values do not match, ensuring the model remains in sync with the selections.


Line range hint 2134-2138: Method onClickCollapseTag functions as intended

The onClickCollapseTag method correctly toggles the collapse state of tags upon user interaction and resets the input height accordingly.


Line range hint 2139-2141: Methods updateSelectedData and hidePanel are implemented correctly

The updateSelectedData and hidePanel methods effectively update the selected data and control the visibility of the panel.

Comment on lines +43 to +44
value: node.id,
isTree: true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent node structure across select scenarios

The isTree property is only added to nodes in the multi-select scenario (场景2), but not in the single select (场景1) or searchable select (场景3) scenarios. This inconsistency could lead to issues in components that consume this data.

Consider applying this change consistently across all scenarios:

// 场景1
updateSelectedData({
  ...data,
  currentLabel: data.label,
  value: data.id,
+ isTree: true,
  state: {
    currentLabel: data.label
  }
})

// 场景3
updateSelectedData({
  ...data,
  currentLabel: data.label,
  value: data.id,
+ isTree: true,
  state: {
    currentLabel: data.label
  }
})

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +43 to +44
value: node.id,
isTree: true
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider standardizing the node structure across all scenarios

While adding isTree: true helps identify tree-sourced selections, I notice this property is only added in the multi-select scenario but not in the single-select or searchable scenarios. This inconsistency could lead to issues when handling selected nodes elsewhere in the application.

Consider applying this change to all three scenarios for consistency:

// Single select scenario
updateSelectedData({
  ...data,
  currentLabel: data.label,
  value: data.id,
+ isTree: true,
  state: {
    currentLabel: data.label
  }
})

// Searchable scenario
updateSelectedData({
  ...data,
  currentLabel: data.label,
  value: data.id,
+ isTree: true,
  state: {
    currentLabel: data.label
  }
})

Committable suggestion skipped: line range outside the PR's diff.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
packages/theme/src/base-select/index.less (1)

206-222: Consider using CSS custom properties for tag heights

While the height definitions are correct, consider using CSS custom properties (variables) for the tag heights to improve maintainability and consistency. This would align with the existing pattern of using CSS variables seen elsewhere in the file (e.g., --tv-BaseSelect-font-size).

Consider refactoring to use CSS custom properties:

  & {
    .@{tag-prefix-cls} {
-     height: 20px;
+     height: var(--tv-BaseSelect-tag-height-default, 20px);
    }
  }

  &--medium {
    .@{tag-prefix-cls} {
-     height: 24px;
+     height: var(--tv-BaseSelect-tag-height-medium, 24px);
    }
  }

  &--small, &--mini {
    .@{tag-prefix-cls} {
-     height: 16px;
+     height: var(--tv-BaseSelect-tag-height-small, 16px);
    }
  }

This change would:

  1. Make it easier to maintain consistent sizing across components
  2. Allow for theme customization without modifying the source code
  3. Follow the existing pattern of using CSS variables in the codebase
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dcb10aa and 1dd8136.

📒 Files selected for processing (6)
  • examples/sites/demos/pc/app/base-select/collapse-tags-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/base-select/slot-panel-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/base-select/slot-panel.vue (1 hunks)
  • packages/renderless/src/base-select/index.ts (1 hunks)
  • packages/theme/src/base-select/index.less (1 hunks)
  • packages/theme/src/select-dropdown/index.less (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/theme/src/select-dropdown/index.less
🔇 Additional comments (5)
examples/sites/demos/pc/app/base-select/collapse-tags-composition-api.vue (2)

36-37: LGTM! New option follows consistent format.

The new option follows the same structure as existing options with appropriate value and label properties.


Line range hint 1-54: Verify alignment with PR objectives.

The PR's objective is to "fix style issues in the old theme", but the changes only add a new option to the demo file. There appear to be no style-related changes that address the stated objective.

Let's verify if there are related style changes in other files:

✅ Verification successful

Style changes have been made to fix tag height issues in the old theme

The PR's objective to "fix style issues in the old theme" is actually addressed through the changes in packages/theme/src/base-select/index.less. The commit 1dd8136 specifically adds new style rules to fix tag height issues for different sizes:

& {
  .@{tag-prefix-cls} {
    height: 20px;
  }
}

&--medium {
  .@{tag-prefix-cls} {
    height: 24px;
  }
}

&--small, &--mini {
  .@{tag-prefix-cls} {
    height: 16px;
  }
}

The demo file changes are complementary to showcase these style fixes in action.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Look for related style changes in base-select component files

# Search for style-related changes in base-select files
rg -l "base-select" | xargs rg -l "\.less|\.css|style"

# Search for theme-related files
fd -g "*theme*.less" -g "*theme*.css"

Length of output: 5627


Script:

#!/bin/bash
# Let's check the content of theme files for base-select style changes
cat packages/theme/src/base-select/index.less

# Also check if there are any recent changes to this file
git log -p packages/theme/src/base-select/index.less

# Check the SAAS theme file as well since it was in the results
cat packages/theme-saas/src/index.less

Length of output: 42861

examples/sites/demos/pc/app/base-select/slot-panel-composition-api.vue (1)

43-44: Verify the purpose and impact of isTree property

Please clarify:

  1. Why is the isTree flag needed?
  2. How does it affect the rendering or behavior of selected items?
  3. Are there any side effects in other components that consume this data?

Let's check how this property is used across the codebase:

✅ Verification successful

Let me gather more context about the tree-related functionality in the select component.


Let me search for more specific information about how the isTree property is used in the select component's logic.


Based on the gathered information, I can now provide a clear explanation about the isTree property's purpose and impact.

The isTree flag is correctly used and necessary for tree-based select functionality

The isTree property is used to:

  1. Signal that the node is part of a tree-based select component when renderType === 'tree'
  2. Enable proper handling of tree-specific data structures and operations:
    • Tree node selection and deselection
    • Handling of parent-child relationships
    • Integration with the tree component's checkbox/radio functionality

Key evidence from the codebase:

  • Used in getPluginOption to handle tree-specific data retrieval
  • Controls tree-specific rendering and behavior in the select component
  • Integrates with treeOp configuration for tree-specific features like checkStrictly
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usages of isTree property in the codebase
echo "Searching for isTree property usage in template files:"
rg "isTree" --type vue -C 3

echo "\nSearching for references in component logic:"
ast-grep --pattern 'isTree'

Length of output: 1331


Script:

#!/bin/bash
# Check the type constants and tree-related configurations
echo "Checking type constants:"
rg "TYPE.Tree" -C 3

echo "\nChecking tree option configurations:"
rg "treeOp" -C 3

echo "\nChecking tree data handling:"
ast-grep --pattern 'getTreeData'

Length of output: 108799


Script:

#!/bin/bash
# Search for the select component's tree-related logic
echo "Checking select component tree handling:"
rg "renderType === .*Tree" -C 3

echo "\nChecking isTree usage in select logic:"
ast-grep --pattern 'const isTree = $_'

echo "\nChecking tree-related plugin options:"
rg "getPluginOption" -C 3

Length of output: 13168

examples/sites/demos/pc/app/base-select/slot-panel.vue (1)

Line range hint 1-65: Inconsistent handling between single and multi-select scenarios

The isTree flag is only added to multi-select scenario (scenario 2) but not to single-select scenarios (1 and 3). This inconsistency might lead to different behavior between selection modes.

Let's verify if this is intentional by checking other tree-select implementations:

✅ Verification successful

The isTree flag is intentionally added only to multi-select scenario

Looking at the actual implementation in packages/vue/src/tree-select/src/pc.vue, which is the core component, we can see that the multi-select mode uses the show-checkbox prop and handles selections through the @check event, while single-select mode uses @node-click. This different handling mechanism justifies having the isTree flag only in the multi-select scenario to properly handle the checkbox-based tree selection.

The examples in both slot-panel.vue and slot-panel-composition-api.vue consistently follow this pattern, showing it's an intentional design choice rather than an inconsistency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other tree-select implementations to verify if this pattern is consistent
ast-grep --pattern 'tiny-base-select $$$
  <template #panel="{ methods: { updateSelectedData $$$} }">
    <tiny-tree
      $$$
      @node-click="$$$"
    ></tiny-tree>
  </template>'

Length of output: 185


Script:

#!/bin/bash
# Let's try a different approach using ripgrep to search for tree-select patterns
rg -U "tiny-base-select.*\n.*tiny-tree.*\n.*updateSelectedData" -A 10

Length of output: 71


Script:

#!/bin/bash
# Let's search for files containing both tiny-base-select and tiny-tree components
fd . -e vue -x sh -c 'if grep -q "tiny-base-select" "$1" && grep -q "tiny-tree" "$1"; then echo "=== $1 ==="; cat "$1"; fi' sh {}

Length of output: 8448

packages/renderless/src/base-select/index.ts (1)

1605-1605: ⚠️ Potential issue

Verify the impact of size map changes.

The size map has been reordered and the 'small' size value has been changed from 36px to 28px, which could affect existing components using the 'small' size.

Run the following script to find components that might be affected by the size change:

✅ Verification successful

Based on the search results, I can now provide a definitive response about the size map changes:

The size map change is safe and aligns with existing component usage.

The change in the small size value from 36px to 28px in base-select is actually fixing an inconsistency with the rest of the component ecosystem. The evidence shows:

  1. The change aligns with the design system's size maps:

    • Aurora theme: { default: 30, mini: 24, ... }
    • SAAS theme: { default: 28, mini: 24, ... }
  2. The original select component already used a more consistent sizing:

    const defaultSizeMap = { default: 32, mini: 24, small: 36, medium: 40 }
  3. The new size map in base-select follows a logical progression:

    const defaultSizeMap = { medium: 40, default: 32, small: 28, mini: 24 }
  4. All component examples in the codebase using size="small" are working with these dimensions, as evidenced by the extensive usage across various components without any size-specific styling overrides.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find components using the 'small' size that might be affected by the size change.

# Test: Search for components using size="small"
rg -A 2 'size=["'\'']small["'\'']' --type vue

# Test: Search for components using :size="'small'"
rg -A 2 ':size=["'\'']small["'\'']' --type vue

# Test: Search for components using v-bind:size="'small'"
rg -A 2 'v-bind:size=["'\'']small["'\'']' --type vue

Length of output: 235


Script:

#!/bin/bash
# Description: Find components using the 'small' size that might be affected by the size change.

# Search for components using size="small" or :size="'small'" in all files
rg -A 2 'size=["'\'']small["'\'']|:size=["'\'']small["'\'']|v-bind:size=["'\'']small["'\'']'

# Search for any references to the defaultSizeMap or size-related configurations
rg -A 2 'defaultSizeMap|sizeMap'

# Search for any TypeScript/JavaScript files importing or using the base-select component
rg -l "from ['\"]\.\./base-select|from ['\"]\.\./\.\.\/base-select"

Length of output: 60207

Comment on lines +218 to +222
&--small, &--mini {
.@{tag-prefix-cls} {
height: 16px;
}
}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Small and mini sizes should have different heights

The current implementation using the same height (16px) for both small and mini sizes in the base-select component is inconsistent with the design system. Throughout the codebase:

  • The base design system defines different heights:

    • Mini size: --tv-size-height-xs: 24px
    • Small size: --tv-size-height-sm: 28px
  • This pattern is consistently followed across multiple components including Select, Button, Form, Picker, etc.

The tag heights should be adjusted to maintain consistency with the design system.

🔗 Analysis chain

Verify if small and mini sizes should share the same height

The current implementation uses the same height (16px) for both small and mini sizes. Please verify if this is intentional, as typically these sizes would have different values.


Based on the search results, I can see that throughout the codebase, small and mini sizes consistently have different heights. Specifically in the base variables (packages/theme/src/base/vars.less), we can see:

--tv-size-height-xs: 24px; // mini 尺寸
--tv-size-height-sm: 28px; // small 尺寸

Let me search for the specific tag height definitions to verify if there's any intentional override.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other size definitions in the codebase to verify consistency
rg --type=less "height.*(?:small|mini)" -A 2 -B 2

Length of output: 25919


Script:

#!/bin/bash
# Search for tag height definitions in the codebase
rg --type=less "tag.*height|--tv-.*tag.*height" -B 2 -A 2

Length of output: 2861

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants