Skip to content

chore(DockView): bump version 9.1.4#374

Merged
ArgoZhang merged 2 commits intomasterfrom
feat-dockview-v4.1.0
Mar 17, 2025
Merged

chore(DockView): bump version 9.1.4#374
ArgoZhang merged 2 commits intomasterfrom
feat-dockview-v4.1.0

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

Link issues

fixes #373

Summary By Copilot

This pull request includes several updates and improvements to the BootstrapBlazor.DockView component, focusing on version updates, CSS adjustments, and JavaScript code refactoring. The most important changes include updating the component version, refining CSS styles, and enhancing JavaScript functions for better performance and maintainability.

Version Update:

  • Updated the version of BootstrapBlazor.DockView from 9.1.3 to 9.1.4 in the csproj file.

CSS Adjustments:

  • Added new CSS variables for tab and action container styling in dockview-bb.css.
  • Modified the height of the .dv-resize-container-drawer class to 100% in dockview-bb.css.
  • Made .dv-default-tab-action visible in inactive tabs in dockview-bb.css.
  • Moved .dv-watermark styling to dockview.css for better organization. [1] [2]

JavaScript Refactoring:

  • Updated the version of dockview-core from 4.0.1 to 4.1.0 in dockview-core.esm.js.
  • Removed redundant addDisposableWindowListener and getElementsByTagName functions, and replaced their usages with addDisposableListener for consistency. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Enhanced the disableIframePointEvents function to efficiently handle shadow DOMs.
  • Introduced onDidWindowMoveEnd and onDidWindowResizeEnd functions for better event handling.
  • Refactored PaneviewPanel and DraggablePaneviewPanel constructors for better readability and maintainability. [1] [2]
  • Added new events onDidPopoutGroupSizeChange and onDidPopoutGroupPositionChange to DockviewComponent for enhanced functionality. [1] [2] [3]

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

@bb-auto bb-auto Bot added the chore label Mar 17, 2025
@bb-auto bb-auto Bot added this to the v9.2.0 milestone Mar 17, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Mar 17, 2025

Reviewer's Guide by Sourcery

This pull request updates the BootstrapBlazor.DockView component to version 9.1.4. The changes include version updates, CSS adjustments, and JavaScript refactoring to improve performance, maintainability, and styling.

Updated class diagram for PaneviewPanel and DraggablePaneviewPanel

classDiagram
    class PaneviewPanel {
        - headerSize: number
        - _orthogonalSize: number
        - _size: number
        - _minimumBodySize: number
        - _maximumBodySize: number
        - _isExpanded: boolean
        + onDidChangeExpansionState: Event
        + onDidChange: Event
        + isExpanded(): boolean
        + layout(width: number, height: number): void
        + init(parameters: any): void
    }
    note for PaneviewPanel "Constructor now takes an options object"
    class DraggablePaneviewPanel {
        - accessor: any
        + onDidDrop: Event
        + onUnhandledDragOverEvent: Event
    }
    note for DraggablePaneviewPanel "Constructor now takes an options object"
    PaneviewPanel <|-- DraggablePaneviewPanel
Loading

Updated class diagram for DockviewComponent

classDiagram
    class DockviewComponent {
        -_onDidPopoutGroupSizeChange: Emitter
        +onDidPopoutGroupSizeChange: Event
        -_onDidPopoutGroupPositionChange: Emitter
        +onDidPopoutGroupPositionChange: Event
        +orthogonalize(position: string, options?: any): void
    }
Loading

File-Level Changes

Change Details Files
Updated the version of BootstrapBlazor.DockView and dockview-core.
  • Updated BootstrapBlazor.DockView version from 9.1.3 to 9.1.4 in the csproj file.
  • Updated dockview-core version from 4.0.1 to 4.1.0 in dockview-core.esm.js.
src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-core.esm.js
Refactored JavaScript code by removing redundant functions and enhancing event handling.
  • Removed addDisposableWindowListener and getElementsByTagName functions, replacing them with addDisposableListener.
  • Enhanced disableIframePointEvents to handle shadow DOMs efficiently.
  • Introduced onDidWindowMoveEnd and onDidWindowResizeEnd functions for improved event handling.
  • Refactored PaneviewPanel and DraggablePaneviewPanel constructors for better readability.
  • Added new events onDidPopoutGroupSizeChange and onDidPopoutGroupPositionChange to DockviewComponent.
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-core.esm.js
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-group.js
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js
Adjusted CSS styles for improved component appearance and organization.
  • Added new CSS variables for tab and action container styling.
  • Modified the height of the .dv-resize-container-drawer class to 100%.
  • Made .dv-default-tab-action visible in inactive tabs.
  • Moved .dv-watermark styling to dockview.css.
src/components/BootstrapBlazor.DockView/wwwroot/css/dockview-bb.css
src/components/BootstrapBlazor.DockView/wwwroot/css/dockview.css

Assessment against linked issues

Issue Objective Addressed Explanation
#373 Bump the version of the BootstrapBlazor.DockView component from 9.1.3 to 9.1.4.
#373 Update the version of dockview-core from 4.0.1 to 4.1.0.

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

@ArgoZhang ArgoZhang merged commit 9003a83 into master Mar 17, 2025
1 check passed
@ArgoZhang ArgoZhang deleted the feat-dockview-v4.1.0 branch March 17, 2025 06:04
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 using a consistent naming scheme for CSS variables (e.g., prefixing all of them with --bb-dockview- to avoid potential conflicts).
  • It looks like you're adding new events to DockviewComponent; ensure these events are properly documented and that their usage is clear.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues 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.

}
}
}
const DEBOUCE_DELAY = 100;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick (typo): Possible typo in constant name.

Consider renaming 'DEBOUCE_DELAY' to 'DEBOUNCE_DELAY' to improve clarity and reduce potential confusion.

Suggested change
const DEBOUCE_DELAY = 100;
const DEBOUNCE_DELAY = 100;

}), _onDidWindowPositionChange.event(() => {
this._onDidPopoutGroupPositionChange.fire({
screenX: _window.window.screenX,
screenY: _window.window.screenX,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Potential incorrect property used in event payload.

The 'screenY' property is being set with '_window.window.screenX'; verify if this is intentional or if it should use '_window.window.screenY'.

}
return true;
}
function onDidWindowMoveEnd(window) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (complexity): Consider extracting the debouncing and recursive shadow DOM logic into small, clearly named helper functions to improve readability and reduce nested control flow complexity.

Consider extracting both the debouncing and recursive shadow DOM logic into clearly named, small helper functions. This will reduce nested control flow and improve readability.

For example, instead of embedding debouncing logic directly in `onDidWindowMoveEnd`, create a debounce helper:

```js
// Option 1: Use a lightweight debounce utility from a library like lodash
import debounce from 'lodash.debounce';

// Or a simple custom debounce helper:
function debounceFn(fn, delay) {
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => fn(...args), delay);
  };
}

function onDidWindowMoveEnd(window) {
  const emitter = new Emitter();
  let previousX = window.screenX;
  let previousY = window.screenY;

  const fireEmitter = debounceFn(() => emitter.fire(), DEBOUCE_DELAY);

  function checkMovement() {
    if (window.closed) return;
    const { screenX, screenY } = window;
    if (screenX !== previousX || screenY !== previousY) {
      fireEmitter();
      previousX = screenX;
      previousY = screenY;
    }
    requestAnimationFrame(checkMovement);
  }
  checkMovement();
  return emitter;
}

Similarly, consider separating the recursive shadow DOM traversal:

function collectMatchingElements(node, tagNames, result = []) {
  if (node.nodeType === Node.ELEMENT_NODE) {
    if (tagNames.includes(node.tagName)) {
      result.push(node);
    }
    if (node.shadowRoot) {
      collectMatchingElements(node.shadowRoot, tagNames, result);
    }
    for (const child of node.children) {
      collectMatchingElements(child, tagNames, result);
    }
  }
  return result;
}

function allTagsNamesInclusiveOfShadowDoms(tagNames) {
  return collectMatchingElements(document.documentElement, tagNames);
}

By isolating these concerns, the overall flow is flatter and easier to follow while keeping functionality intact.

Comment on lines +521 to +533
function findIframesInNode(node) {
if (node.nodeType === Node.ELEMENT_NODE) {
if (tagNames.includes(node.tagName)) {
iframes.push(node);
}
if (node.shadowRoot) {
findIframesInNode(node.shadowRoot);
}
for (const child of node.children) {
findIframesInNode(child);
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (code-quality): Avoid function declarations, favouring function assignment expressions, inside blocks. (avoid-function-declarations-in-blocks)

ExplanationFunction declarations may be hoisted in Javascript, but the behaviour is inconsistent between browsers. Hoisting is generally confusing and should be avoided. Rather than using function declarations inside blocks, you should use function expressions, which create functions in-scope.

Comment on lines +631 to +637
const disposable = new CompositeDisposable(addDisposableListener(element, 'resize', () => {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
cb();
}, DEBOUCE_DELAY);
}));
return disposable;
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): Inline variable that is immediately returned (inline-immediately-returned-variable)

Suggested change
const disposable = new CompositeDisposable(addDisposableListener(element, 'resize', () => {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
cb();
}, DEBOUCE_DELAY);
}));
return disposable;
return new CompositeDisposable(addDisposableListener(element, 'resize', () => {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
cb();
}, DEBOUCE_DELAY);
}));


ExplanationSomething that we often see in people's code is assigning to a result variable
and then immediately returning it.

Returning the result directly shortens the code and removes an unnecessary
variable, reducing the mental load of reading the function.

Where intermediate variables can be useful is if they then get used as a
parameter or a condition, and the name can act like a comment on what the
variable represents. In the case where you're returning it from a function, the
function name is there to tell you what the result is, so the variable name
is unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(DockView): bump version 9.1.4

2 participants