Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Nov 19, 2024

redesign TreeView dom structure

Summary of the changes (Less than 80 chars)

简单描述你更改了什么, 不超过80个字符;如果有关联 Issue 请在下方填写相关编号

Description

fixes #4695

Regression?

  • Yes
  • No

[If yes, specify the version the behavior has regressed from]

[是否影响老版本]

Risk

  • High
  • Medium
  • Low

[Justify the selection above]

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Redesign the TreeView component's DOM structure to enhance its layout and styling, and update the corresponding unit tests to reflect these changes.

Enhancements:

  • Redesign the DOM structure of the TreeView component to improve its layout and styling.

Tests:

  • Update unit tests for the TreeView component to align with the new DOM structure.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 19, 2024

Reviewer's Guide by Sourcery

This PR redesigns the TreeView component's DOM structure by flattening the nested ul/li hierarchy into a simpler div-based layout. The changes improve the component's structure while maintaining existing functionality through updated selectors and styling.

Updated class diagram for TreeView component

classDiagram
    class TreeView {
        +bool IsDisabled
        +bool CanExpandWhenDisabled
        +List~TreeViewItem~ Rows
        +RenderFragment~TreeViewItem~ RenderTreeRow
        +string? GetContentClassString(TreeViewItem item)
        +bool CanTriggerClickNode(TreeViewItem item)
        +Task OnClick(TreeViewItem item)
    }
    class TreeViewItem {
        +bool IsDisabled
        +bool HasChildren
        +List~TreeViewItem~ Items
        +TreeViewItem Parent
    }
    TreeView o-- TreeViewItem
    note for TreeView "Redesigned DOM structure with div-based layout"
Loading

Updated class diagram for CSS changes in TreeView

classDiagram
    class TreeViewCSS {
        +--bb-tree-padding
        +--bb-tree-margin
        +--bb-tree-padding-left
        +--bb-tree-item-margin
        +--bb-tree-icon-width
        +--bb-tree-check-margin
        +--bb-tree-disabled-opacity
        +--bb-tree-item-active-color
        +--bb-tree-item-active-bg
        +--bb-tree-item-hover-bg
    }
    note for TreeViewCSS "Updated CSS variables and structure for TreeView"
Loading

File-Level Changes

Change Details Files
Simplified DOM structure by removing nested ul/li elements
  • Replaced nested ul/li hierarchy with flat div structure
  • Updated CSS classes and selectors to work with new structure
  • Moved level-based indentation to CSS variable --bb-tree-view-level
  • Renamed CSS variable from --bb-tree-ul-padding-left to --bb-tree-padding-left
src/BootstrapBlazor/Components/TreeView/TreeView.razor
src/BootstrapBlazor/Components/TreeView/TreeView.razor.scss
src/BootstrapBlazor/wwwroot/scss/theme/bootstrapblazor.scss
Improved test structure and assertions
  • Updated element selectors to match new DOM structure
  • Converted synchronous tests to async where needed
  • Added more specific assertions for component states
  • Improved test readability with better variable names
test/UnitTest/Components/TreeViewTest.cs
test/UnitTest/Components/SelectTreeTest.cs
Enhanced component behavior and state management
  • Improved disabled state handling logic
  • Updated node expansion logic to consider HasChildren property
  • Refactored click handling and node toggling logic
  • Added preventDefault to checkbox click events
src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs
src/BootstrapBlazor/Components/Checkbox/Checkbox.razor.js
src/BootstrapBlazor/Misc/ExpandableNodeCache.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#4695 Redesign TreeView DOM structure to improve organization and maintainability

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added the enhancement New feature or request label Nov 19, 2024
@bb-auto bb-auto bot added this to the v9.0.0 milestone Nov 19, 2024
@ArgoZhang ArgoZhang enabled auto-merge (squash) November 19, 2024 06:42
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ArgoZhang - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please add documentation about the DOM structure changes and migration notes for users who may have custom CSS targeting the old ul/li structure.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (4673c39) to head (661b584).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #4696   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          620       620           
  Lines        27388     27378   -10     
  Branches      3926      3923    -3     
=========================================
- Hits         27388     27378   -10     

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


🚨 Try these New Features:

@ArgoZhang ArgoZhang merged commit ac8ea57 into main Nov 19, 2024
5 checks passed
@ArgoZhang ArgoZhang deleted the refactor-tree branch November 19, 2024 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(TreeView): redesign TreeView dom structure

2 participants