Skip to content

feat(DockView2): collapse panel to nearest edge#394

Merged
ArgoZhang merged 9 commits intomasterfrom
feat-dockview-autoHide
Mar 29, 2025
Merged

feat(DockView2): collapse panel to nearest edge#394
ArgoZhang merged 9 commits intomasterfrom
feat-dockview-autoHide

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Mar 29, 2025

Link issues

fixes #393

Summary By Copilot

This pull request includes several updates to the BootstrapBlazor.DockView component, focusing on version updates, CSS adjustments, and JavaScript enhancements for better handling of dockview elements. The most important changes include updating the project version, removing dark theme CSS rules, adding new CSS variables and rules, and modifying JavaScript functions to handle new parameters and behaviors.

Version Update:

CSS Adjustments:

JavaScript Enhancements:

These updates aim to improve the flexibility, usability, and maintainability of the BootstrapBlazor.DockView component.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

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

Enhance DockView component to support collapsing panels to the nearest edge with improved drawer and aside functionality

New Features:

  • Add support for collapsing panels to left or right edges with dynamic positioning
  • Implement configurable drawer functionality with improved user interaction

Enhancements:

  • Refactor CSS to remove dark theme specific rules
  • Improve panel positioning and overlay handling
  • Add more flexible panel interaction mechanisms

Chores:

  • Update project version from 9.1.8 to 9.1.9

@bb-auto bb-auto Bot added the enhancement New feature or request label Mar 29, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Mar 29, 2025

Reviewer's Guide by Sourcery

This pull request introduces a feature that allows panels to collapse to the nearest edge. It includes updates to the project version, CSS adjustments, and JavaScript enhancements for better handling of dockview elements. The changes involve updating the project version, removing dark theme CSS rules, adding new CSS variables and rules, and modifying JavaScript functions to handle new parameters and behaviors.

Sequence diagram for autoHide function

sequenceDiagram
    participant Group
    participant Dockview
    participant FloatingGroup

    Group->>Group: getParams()
    alt canFloat(group)
        Group->>Dockview: createFloatingGroup(group, rect, 'drawer')
        Dockview->>FloatingGroup: createFloatingGroup(group, rect, 'drawer')
        FloatingGroup-->>Dockview: floatingGroup
        alt floatingGroup
            Dockview->>FloatingGroup: createDrawerHandle(floatingGroup, isRight)
            Dockview->>Dockview: saveConfig(dockview)
        end
    else canFloat(group) == false
        Group-->>Group: return
    end
Loading

Sequence diagram for createDrawerHandle function

sequenceDiagram
    participant FloatingGroup
    participant Dockview

    FloatingGroup->>FloatingGroup: element.parentElement.classList.add('dv-resize-container-drawer')
    FloatingGroup->>FloatingGroup: element.parentElement.classList.add(className)
    FloatingGroup->>FloatingGroup: createDrawerBtn(floatingGroup, isRight)

    FloatingGroup->>Dockview: btn.addEventListener('click')
    activate Dockview
    Dockview->>FloatingGroup: fgWrapper.classList.contains('active')
    alt fgWrapper.classList.contains('active')
        FloatingGroup->>FloatingGroup: fgWrapper.classList.remove('active')
        FloatingGroup->>FloatingGroup: parentElement.classList.remove('active')
    else not fgWrapper.classList.contains('active')
        FloatingGroup->>FloatingGroup: btn.classList.add('active')
        FloatingGroup->>FloatingGroup: fgWrapper.classList.add('active')
        FloatingGroup->>FloatingGroup: parentElement.classList.add('active')
    end
    Dockview->>Dockview: saveConfig(dockview)
    deactivate Dockview
Loading

Updated class diagram for Overlay

classDiagram
  class Overlay {
    - _element: HTMLElement
    - options: Object
    + Overlay(options: Object)
    + getElement(): HTMLElement
  }
  note for Overlay "Added className option to Overlay class for better customization"
Loading

File-Level Changes

Change Details Files
Updated the project version.
  • Updated the project version from 9.1.8 to 9.1.9.
src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj
Adjusted CSS styles for dockview elements.
  • Removed dark theme CSS rules.
  • Added new CSS variables for dockview elements, including aside width.
  • Added new CSS rules for dockview elements, including hover effects.
src/components/BootstrapBlazor.DockView/wwwroot/css/dockview-bb.css
Enhanced JavaScript classes for customization.
  • Enhanced the Overlay class to include optional class names.
  • Enhanced the DockviewComponent class to include optional class names.
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-core.esm.js
Updated JavaScript functions to handle new parameters and behaviors.
  • Updated functions to handle new parameters such as direction.
  • Improved logic for drawer handling.
  • Improved logic for overlay changes.
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-group.js
Modified the initDockview function to observe new parameters and handle click events.
  • Modified the initDockview function to observe new parameters.
  • Modified the initDockview function to handle click events for better user interaction.
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js

Assessment against linked issues

Issue Objective Addressed Explanation
#393 Collapse the DockView panel to the nearest edge.

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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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 this to the v9.2.0 milestone Mar 29, 2025
@ArgoZhang ArgoZhang merged commit 20105fd into master Mar 29, 2025
1 check passed
@ArgoZhang ArgoZhang deleted the feat-dockview-autoHide branch March 29, 2025 01:32
Copy link
Copy Markdown

@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:

  • Consider adding comments to the javascript code to explain the purpose and functionality of the functions.
  • It might be helpful to include a brief explanation of the new CSS variables and their intended use in the CSS file.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 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.

dockview.groups.forEach(group => {
observeGroup(group)
})
dockview.element.querySelector('&>.dv-dockview>.dv-branch-node').addEventListener('click', function (e) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (bug_risk): Review use of '&>' in query selectors.

Standard querySelector syntax does not support the '&>' combinator. It is advisable to replace '&>' with the appropriate direct child selector (e.g., '>') to ensure reliable element selection in all browsers.

Suggested implementation:

            dockview.element.querySelector('> .dv-dockview > .dv-branch-node').addEventListener('click', function (e) {
                this.parentElement.querySelectorAll('> .dv-resize-container-drawer').forEach(item => {
                this.closest('.bb-dockview').querySelectorAll('> .bb-dockview-aside > .bb-dockview-aside-button').forEach(item => {

})
if (fgWrapper.style.left == '-1px') {
fgWrapper.style.left = '-9999px'
btn.parentElement.parentElement.querySelectorAll('&>.bb-dockview-aside>.bb-dockview-aside-button').forEach(btnEle => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (bug_risk): Correct the child combinator selector to avoid errors.

Similar to the previous query selector issue, the use of '&>' is non-standard. Please update these selectors to use the correct syntax for directly targeting child elements (e.g. ">.bb-dockview-aside > .bb-dockview-aside-button") to ensure proper element matching.

Suggested change
btn.parentElement.parentElement.querySelectorAll('&>.bb-dockview-aside>.bb-dockview-aside-button').forEach(btnEle => {
btn.parentElement.parentElement.querySelectorAll('>.bb-dockview-aside > .bb-dockview-aside-button').forEach(btnEle => {


const createDrawerHandle = (floatingGroup) => {
function getOffsetFromDockview(element) {
let offsetLeft = element.offsetLeft;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring)

Suggested change
let offsetLeft = element.offsetLeft;
let {offsetLeft} = element;


ExplanationObject destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the Airbnb Javascript Style Guide

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.

feat(DockView2): collapse panel to nearest edge

2 participants