Skip to content

bug(DockView): fix title incorrect when switch lang#955

Merged
ArgoZhang merged 3 commits intomasterfrom
fix-dockview
Mar 18, 2026
Merged

bug(DockView): fix title incorrect when switch lang#955
ArgoZhang merged 3 commits intomasterfrom
fix-dockview

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Mar 18, 2026

Link issues

fixes #954

Summary By Copilot

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

Bug Fixes:

  • Correct panel deletion logic when moving panels between groups to preserve panel state, including titles, during language switches.

Copilot AI review requested due to automatic review settings March 18, 2026 06:39
@bb-auto bb-auto bot added the bug Something isn't working label Mar 18, 2026
@bb-auto bb-auto bot added this to the v9.2.0 milestone Mar 18, 2026
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 18, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes DockView panel deletion logic when toggling components to ensure the correct panel instance is removed, which resolves incorrect titles after language switches.

Sequence diagram for DockView toggleComponent panel deletion fix

sequenceDiagram
    actor User
    participant DockViewUI
    participant dockview_utils_js
    participant dockview_group_js
    participant DockviewInstance

    User->>DockViewUI: Switch language / toggle component
    DockViewUI->>dockview_utils_js: toggleComponent(dockview, options)
    dockview_utils_js->>DockviewInstance: getPanels()
    DockviewInstance-->>dockview_utils_js: panels
    loop For each panel p in panels
        dockview_utils_js->>dockview_group_js: addGroupWithPanel(dockview, p_or_panel, localPanel, panels, index)
        alt Panel has groupId
            dockview_group_js->>DockviewInstance: addPanelWidthGroupId(dockview, panel, index)
        else Panel has no groupId
            dockview_group_js->>DockviewInstance: addPanelWidthCreatGroup(dockview, panel, panels)
        end
        note over dockview_group_js,DockviewInstance: Corrected behavior: deletePanel now uses localPanel
        dockview_group_js->>DockviewInstance: deletePanel(dockview, localPanel)
    end
    DockviewInstance-->>DockViewUI: Panels updated with correct titles after lang switch
Loading

File-Level Changes

Change Details Files
Correct function signature and deletion behavior when adding a group with a panel so that the original panel instance is deleted instead of the newly created/translated one.
  • Extend addGroupWithPanel to accept both the original local panel and the target panel instance
  • Update deletePanel invocation to use the original local panel reference rather than the panel that was added to the group
  • Adjust toggleComponent to pass both the toggled panel and the existing panel instance into addGroupWithPanel in the correct order
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-group.js
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js

Assessment against linked issues

Issue Objective Addressed Explanation
#954 Fix the DockView panel title being incorrect after switching language.

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. 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!

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 fb2d6dd into master Mar 18, 2026
3 checks passed
@ArgoZhang ArgoZhang deleted the fix-dockview branch March 18, 2026 06:39
Copy link

@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 - I've found 1 issue, and left some high level feedback:

  • The change to addGroupWithPanel now prefers p over panel (p || panel instead of panel || p); if both can be defined this may alter behavior in subtle ways and is worth confirming aligns with the intended source of truth.
  • Since localPanel can now be undefined when passed into deletePanel, consider adding a guard or clarifying the expected invariants to make the deletion logic more robust and self-documenting.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The change to `addGroupWithPanel` now prefers `p` over `panel` (`p || panel` instead of `panel || p`); if both can be defined this may alter behavior in subtle ways and is worth confirming aligns with the intended source of truth.
- Since `localPanel` can now be `undefined` when passed into `deletePanel`, consider adding a guard or clarifying the expected invariants to make the deletion logic more robust and self-documenting.

## Individual Comments

### Comment 1
<location path="src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-group.js" line_range="29-36" />
<code_context>
 }

-const addGroupWithPanel = (dockview, panel, panels, index) => {
+const addGroupWithPanel = (dockview, panel, localPanel, panels, index) => {
     if (panel.groupId) {
         addPanelWidthGroupId(dockview, panel, index)
     }
     else {
         addPanelWidthCreatGroup(dockview, panel, panels)
     }
-    deletePanel(dockview, panel)
+    deletePanel(dockview, localPanel)
 }

</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against `localPanel` being undefined before calling `deletePanel`.

With the new signature, `localPanel` may be `undefined` when `panels.find(...)` in the caller fails, leading to `deletePanel(dockview, undefined)`. Please either guard before calling (e.g. `if (localPanel) deletePanel(...)`) or ensure the caller always provides a valid panel reference.
</issue_to_address>

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.

Comment on lines +29 to +36
const addGroupWithPanel = (dockview, panel, localPanel, panels, index) => {
if (panel.groupId) {
addPanelWidthGroupId(dockview, panel, index)
}
else {
addPanelWidthCreatGroup(dockview, panel, panels)
}
deletePanel(dockview, panel)
deletePanel(dockview, localPanel)
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Guard against localPanel being undefined before calling deletePanel.

With the new signature, localPanel may be undefined when panels.find(...) in the caller fails, leading to deletePanel(dockview, undefined). Please either guard before calling (e.g. if (localPanel) deletePanel(...)) or ensure the caller always provides a valid panel reference.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an issue in the DockView JavaScript integration where panel titles could remain incorrect after switching languages, by preferring the latest panel definition from options when re-adding panels and cleaning up stale stored panel metadata.

Changes:

  • Update toggleComponent to re-add panels using the current option panel (with updated title) instead of a cached/stored panel instance.
  • Adjust addGroupWithPanel to accept both the panel-to-add and the stored panel instance to delete from dockview.params.panels.
  • Bump BootstrapBlazor.DockView package version to 10.0.4-beta01.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js Prefer option-derived panel when adding a panel during toggle (helps ensure updated titles are used).
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-group.js Extend addGroupWithPanel to delete the correct stored panel instance after re-adding.
src/components/BootstrapBlazor.DockView/BootstrapBlazor.DockView.csproj Update package version for the DockView component.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


<PropertyGroup>
<Version>10.0.3</Version>
<Version>10.0.4-beta01</Version>
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.

bug(DockView): fix title incorrect when switch lang

3 participants