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: fix grid、flowchart、grid、tree-menu bugs #2588

Merged
merged 1 commit into from
Dec 2, 2024
Merged

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Dec 2, 2024

PR

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

    • Introduced new CSS variables for enhanced theme flexibility.
    • Added a new dependency to the grid package for improved functionality.
  • Improvements

    • Updated the rendering logic for the upload component to refine display conditions.
    • Enhanced the grid component's responsiveness with new styles for various states and sizes.
  • Refactor

    • Simplified props handling in the TreeMenu component for better maintainability.
  • Bug Fixes

    • Improved the logic for clearing active states in the table component based on user interactions.

Copy link

coderabbitai bot commented Dec 2, 2024

Walkthrough

This pull request includes several modifications across various files, primarily focusing on dependency management, component structure, and styling adjustments. Key changes involve the removal of specific dependencies, updates to import paths, and alterations to CSS properties for better component responsiveness. Notably, the TreeMenu component has undergone refactoring to centralize its props definition. Additionally, several LESS files have been updated to enhance layout and styling consistency across components.

Changes

File Path Change Summary
examples/sites/package.json Removed @opentiny/vue-mobile from devDependencies.
packages/modules.json Removed TreeMenuPc entry from module exports.
packages/renderless/src/flowchart/index.ts Adjusted refresh function to improve handling of graphWidth parameter.
packages/renderless/types/tree-menu.type.ts Updated import path for treeMenuProps to @/tree-menu/src/props.ts.
packages/theme-saas/src/cascader-menu/index.less Changed height to min-height for & &__wrap class.
packages/theme-saas/src/date-range/index.less Modified margin properties in &__content class for header alignment.
packages/theme-saas/src/grid/mixins/table.less Updated .CellEllipsis() mixin to handle header cell layout changes.
packages/theme-saas/src/grid/table.less Added new styles for grid table states and sizes, including hover effects and loading indicators.
packages/theme-saas/src/picker/index.less Updated text sizes for range picker components.
packages/theme/src/old-theme-index.js Added new CSS variables for border radius and spacing.
packages/vue/src/file-upload/src/mobile-first.vue Refined conditional rendering logic for upload component based on isText and displayOnly.
packages/vue/src/grid/package.json Added dependency "@opentiny/vue-directive": "workspace:~".
packages/vue/src/grid/src/radio/src/radio.ts Enhanced component by adding AutoTip directive and refactoring label rendering logic.
packages/vue/src/grid/src/table/src/utils/handleGlobalMousedownEvent.ts Modified logic for clearing active state based on user interactions.
packages/vue/src/tree-menu/index.ts Updated import for TreeMenu from ./src/index to ./src/pc.vue.
packages/vue/src/tree-menu/src/pc.vue Refactored props handling to use treeMenuProps and removed unused imports.
packages/vue/src/tree-menu/src/props.ts Removed defineComponent export and added widthAdapt property to treeMenuProps.

Possibly related PRs

Suggested labels

bug

Poem

🐇 In the garden of code, we hop and play,
With styles and props, we brighten the day.
Dependencies trimmed, like grass in the sun,
Our components now dance, oh what a fun run!
With each little change, our project will bloom,
Together we'll code, dispelling all gloom! 🌼


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.

@github-actions github-actions bot added the bug Something isn't working label Dec 2, 2024
Copy link

github-actions bot commented Dec 2, 2024

[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: 1

🧹 Outside diff range and nitpick comments (5)
packages/vue/src/tree-menu/src/props.ts (1)

Line range hint 89-93: Improve documentation and naming for the new prop.

  1. The comment "metaErp" reveals internal implementation details and should be removed or clarified.
  2. The widthAdapt prop lacks documentation about its purpose and usage.
  3. Consider a more descriptive name like adaptiveWidth or autoWidth.
-  // metaErp 新增属性
-  widthAdapt: {
+  /**
+   * Enable automatic width adaptation for the tree menu
+   * @default false
+   */
+  adaptiveWidth: {
     type: Boolean,
     default: false
   }
packages/vue/src/grid/src/radio/src/radio.ts (1)

53-63: Consider adding error handling for missing slots

The labelContent function handles Vue version compatibility well, but it might throw an error if slots.default is undefined.

Consider adding a null check:

 const labelContent = () => {
   let content = h(
     'span',
     { class: 'tiny-grid-radio__label', directives: isVue2 ? [{ name: 'AutoTip' }] : null },
-    $slots.default()
+    $slots.default?.() || ''
   )
   if (!isVue2) {
     hooks.withDirectives(content, [[AutoTip]])
   }
   return content
 }
packages/vue/src/grid/src/table/src/utils/handleGlobalMousedownEvent.ts (1)

79-85: Consider improving readability and performance

While the logic is correct, the condition checking could be more readable and performant.

Consider extracting the conditions and caching DOM queries:

- const tableContent = _vm.$refs.tableBody?.$refs.table
+ const { tableHeader, tableBody } = _vm.$refs
+ const tableContent = tableBody?.$refs.table
+ const headerEl = tableHeader?.$el
+ 
+ const isOutsideTable = !_vm.getEventTargetNode(event, $el).flag
+ const isInHeader = headerEl?.contains(event.target)
+ const isOutsideContent = tableContent && !tableContent.contains(event.target)
+ 
  if (
    isClear ||
-   !_vm.getEventTargetNode(event, $el).flag ||
-   (_vm.$refs.tableHeader && _vm.$refs.tableHeader.$el.contains(event.target)) ||
-   (tableContent && !tableContent.contains(event.target))
+   isOutsideTable ||
+   isInHeader ||
+   isOutsideContent
  )
packages/vue/src/tree-menu/src/pc.vue (1)

135-135: Document the purpose of mono parameter.

The addition of mono: true in the setup function needs documentation to explain its purpose and impact.

Add a comment explaining the purpose of the mono parameter:

- setup(props, context) {
-   return setup({ props, context, renderless, api, mono: true })
+ // mono: true enables single-instance mode for renderless logic
+ setup(props, context) {
+   return setup({ props, context, renderless, api, mono: true })

Also applies to: 137-137

packages/theme/src/old-theme-index.js (1)

5-5: LGTM: New theme variables enhance flexibility.

The addition of new CSS variables (--tv-border-radius-brand, --tv-space-xxl, --tv-space-xxxl) enhances theme customization options.

Consider adding comments to document the intended use cases for these new variables in the theme documentation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 69ebb7c and 5b55bec.

⛔ Files ignored due to path filters (1)
  • packages/theme/src/svgs/ellipsis.svg is excluded by !**/*.svg
📒 Files selected for processing (17)
  • examples/sites/package.json (1 hunks)
  • packages/modules.json (0 hunks)
  • packages/renderless/src/flowchart/index.ts (1 hunks)
  • packages/renderless/types/tree-menu.type.ts (1 hunks)
  • packages/theme-saas/src/cascader-menu/index.less (1 hunks)
  • packages/theme-saas/src/date-range/index.less (1 hunks)
  • packages/theme-saas/src/grid/mixins/table.less (1 hunks)
  • packages/theme-saas/src/grid/table.less (0 hunks)
  • packages/theme-saas/src/picker/index.less (2 hunks)
  • packages/theme/src/old-theme-index.js (1 hunks)
  • packages/vue/src/file-upload/src/mobile-first.vue (1 hunks)
  • packages/vue/src/grid/package.json (1 hunks)
  • packages/vue/src/grid/src/radio/src/radio.ts (4 hunks)
  • packages/vue/src/grid/src/table/src/utils/handleGlobalMousedownEvent.ts (1 hunks)
  • packages/vue/src/tree-menu/index.ts (1 hunks)
  • packages/vue/src/tree-menu/src/pc.vue (2 hunks)
  • packages/vue/src/tree-menu/src/props.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/modules.json
  • packages/theme-saas/src/grid/table.less
✅ Files skipped from review due to trivial changes (1)
  • packages/renderless/types/tree-menu.type.ts
🔇 Additional comments (13)
packages/vue/src/tree-menu/index.ts (1)

12-12: Verify the impact of import path change

The import path change from './src/index' to './src/pc.vue' might affect existing imports and component registration.

✅ Verification successful

Based on the comprehensive search results, I can now generate the final response:

Import path change is safe and intentional

The change from './src/index' to './src/pc.vue' is part of a valid structural reorganization, as evidenced by:

  1. The component is properly registered and exported in the new location (pc.vue)
  2. No other files in the codebase are importing from the old path './src/index'
  3. The component's functionality is maintained in pc.vue with all necessary features
  4. The change aligns with the component's registration in modules.json
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any other files still importing from the old path
rg -l "from.*['\"].*tree-menu/src/index['\"]"

# Check if there are any direct imports of TreeMenuPc
rg -l "TreeMenuPc"

Length of output: 70


Script:

#!/bin/bash
# Let's try a broader search to understand the tree-menu usage
rg -l "tree-menu"

# Check the content of the old index file if it exists
fd "index.(ts|js|vue)" packages/vue/src/tree-menu -x cat {}

# Check the content of pc.vue
fd "pc.vue" packages/vue/src/tree-menu -x cat {}

# Look for any TreeMenu imports or usage patterns
rg "TreeMenu" -A 2

Length of output: 64204

packages/theme-saas/src/cascader-menu/index.less (1)

21-21: LGTM! Good improvement for UI flexibility

Changing from fixed height to min-height is a good improvement that prevents content truncation while maintaining the minimum size requirement.

packages/vue/src/grid/package.json (1)

19-19: LGTM! Verify dependency consistency.

The addition of @opentiny/vue-directive as a workspace dependency is appropriate for the AutoTip directive integration.

✅ Verification successful

Let me verify the actual dependency configuration in these files to ensure consistent versioning.


Dependency configuration is consistent across all packages

The @opentiny/vue-directive dependency is consistently configured with workspace:~ version specifier across all packages that use it, including the grid package. This maintains uniform version management throughout the workspace.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify consistent workspace protocol usage across related packages
rg -l "\"@opentiny/vue-directive\":" | xargs grep -l "workspace:" || echo "No inconsistencies found"

Length of output: 436


Script:

#!/bin/bash
# Check the exact dependency configuration in the identified files
for file in $(rg -l '"@opentiny/vue-directive":'); do
  echo "=== $file ==="
  grep '"@opentiny/vue-directive":' "$file"
done

Length of output: 2746

packages/vue/src/tree-menu/src/props.ts (1)

2-2: LGTM! Import organization looks good.

The import of $props from @opentiny/vue-common is appropriate for props composition.

packages/theme-saas/src/date-range/index.less (1)

70-71: LGTM! Improved layout flexibility.

The changes enhance the header's layout by:

  1. Using auto margins for better centering
  2. Adding consistent line height with Tailwind's leading-5
examples/sites/package.json (1)

90-90: Unable to review the dependency changes

The annotated code only shows a closing brace, while the AI summary mentions removal of @opentiny/vue-mobile. Without seeing the actual changes, I cannot provide a meaningful review of the dependency modifications.

packages/vue/src/grid/src/radio/src/radio.ts (2)

25-25: LGTM: Dependencies and directive registration

The imports and directive registration are properly structured for both Vue 2 and Vue 3 compatibility.

Also applies to: 27-27, 39-39


99-99: LGTM: Proper slot handling in render

The conditional rendering of labelContent based on slot existence is correct.

packages/vue/src/grid/src/table/src/utils/handleGlobalMousedownEvent.ts (1)

79-85: Verify the impact on table selection behavior

The new condition for clearing active state might affect table selection behavior when clicking between header and content areas.

packages/vue/src/tree-menu/src/pc.vue (1)

107-108: Verify icon usage after removing iconSearch import.

The removal of iconSearch import suggests changes in icon handling. Please verify that search functionality still works correctly with the new icon implementation.

✅ Verification successful

The removal of iconSearch import is safe as it's now imported through props

The iconSearch import was moved to the props.ts file where it's properly handled as a default value for the search icon prop. This is a good refactoring practice as it centralizes prop definitions and their default values.

  • The search functionality remains intact as verified by:
    • iconSearch is properly imported and used in packages/vue/src/tree-menu/src/props.ts
    • It's set as the default value for the search icon prop: default: () => iconSearch()
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for iconSearch usage in the codebase
rg "iconSearch" --type vue

Length of output: 54


Script:

#!/bin/bash
# Search for iconSearch usage with ripgrep, without file type filter
rg "iconSearch"

# Also check for any search-related icon imports
rg "icon.*Search" -A 2

# Look for template usage of search icons
rg "<.*search.*icon" -i

Length of output: 40978

packages/theme-saas/src/picker/index.less (1)

149-149: LGTM: Text size standardization improves consistency.

The changes standardize text sizes from text-xs to text-sm across different picker variants, which improves visual consistency.

Also applies to: 153-153, 241-241

packages/renderless/src/flowchart/index.ts (1)

293-297: LGTM! Good fix for the browser zoom issue.

The fix correctly handles the browser zoom discrepancy by adjusting the graphWidth value. The comment clearly explains the rationale, and the code includes proper bounds checking to prevent negative values.

Let's verify the impact of this change on different zoom levels:

✅ Verification successful

The graphWidth adjustment is safe and doesn't cause cascading issues

The code search reveals that the graphWidth adjustment is properly isolated:

  • The adjustment only happens in the refresh function where the browser zoom issue is handled
  • Other usages of graphWidth work with the adjusted value:
    • In layout calculations (afterConfig.layout)
    • In width calculations considering minWidth (graph.width)
    • In the Vue component's resize handling

The fix is well-contained and the adjusted value is consistently used throughout the flow, making it a safe change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for other graphWidth usages to ensure the fix doesn't cause issues elsewhere

# Check for other graphWidth references
rg -A 3 "graphWidth" --type ts

Length of output: 2725

packages/vue/src/file-upload/src/mobile-first.vue (1)

676-676: LGTM! Improved conditional rendering logic.

The change correctly prevents the upload component from rendering when in display-only mode while maintaining proper slot handling.

Comment on lines +36 to +40
// 表头布局从block改为了flex,此处兼容插槽文本溢出不显示省略号问题
&:not(:has(.tiny-grid-cell-text)) > span:only-of-type {
@apply text-ellipsis;
@apply overflow-hidden;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider browser compatibility for :has() selector

While the fix for the text overflow issue is elegant, the :has() selector has limited browser support.

Consider adding a fallback solution or using a more widely supported approach:

- &:not(:has(.tiny-grid-cell-text)) > span:only-of-type {
+ // Fallback solution
+ &:not(.has-cell-text) > span:only-of-type {
   @apply text-ellipsis;
   @apply overflow-hidden;
 }

Also, add a class toggle in the component's mounted hook:

mounted() {
  const hasCellText = this.$el.querySelector('.tiny-grid-cell-text');
  if (!hasCellText) {
    this.$el.classList.add('has-cell-text');
  }
}

@kagol kagol merged commit 2932cbe into dev Dec 2, 2024
7 checks passed
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