Skip to content

fix(DockView): stop sibling blanking on any exit-maximize#1044

Merged
ArgoZhang merged 3 commits into
masterfrom
fix-dockview
Jun 24, 2026
Merged

fix(DockView): stop sibling blanking on any exit-maximize#1044
ArgoZhang merged 3 commits into
masterfrom
fix-dockview

Conversation

@zhaijunlei955

@zhaijunlei955 zhaijunlei955 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Issues

close #1045

Two fixes around the onlyWhenVisible renderer and visibility transitions.

1. Active panel resets to the first / blanks after becoming visible

Problem: Activate a non-first panel in a group, switch to another view (so this
DockView's container is hidden), refresh, then switch back — the group's active
panel snaps to the first one and its content goes blank (tab titles remain).

Cause: setWidth's tab-overflow fallback force-activated group.panels[0]
whenever the visible tab strip had no active tab. On becoming visible after a
hidden init the group expands through narrow widths and transiently overflows the
active tab into the dropdown → reads as "no active tab" → wrong switch + churn.

Fix: Only re-pick the active tab on a real shrink (header width strictly drops,
never the transient expand), switching before the active tab is tucked away. The
remaining fallback fires only when the group genuinely has no active panel.

2. Blank DockView when a group is removed/moved/added/hidden while maximized

Problem: With a grid group maximized, closing all its panels (or otherwise
removing/moving/adding/hiding a group) leaves the whole DockView blank.

Cause: The core exits maximize on its own for those operations
(gridview.removeView/setViewVisible/moveView/addView), but without the
maximizing flag the onlyWhenVisible handler moves the restored siblings'
content into the template → blank. Earlier fixes (e.g. #1025) only set the flag on
the toggle-button and save paths.

Fix: A single guard wraps the core's exitMaximizedView so every exit-maximize
carries the maximizing flag, covering all paths at once.

Summary by Sourcery

Guard DockView maximize exits and refine active-panel selection during tab overflow handling to prevent panels and views from becoming blank after visibility or layout changes.

Bug Fixes:

  • Ensure exiting a maximized grid view always carries the maximizing flag so sibling groups restore their content instead of rendering blank when groups are added, removed, moved, or hidden.
  • Adjust tab overflow handling to only reselect the first panel on genuine header width shrink and when a group has no active panel, preventing active panels from resetting or going blank after visibility transitions.

@bb-auto

bb-auto Bot commented Jun 23, 2026

Copy link
Copy Markdown

Thanks for your PR, @zhaijunlei955. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@sourcery-ai

sourcery-ai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a guard to ensure all maximize exits carry the maximizing flag, and refines tab overflow handling so active panels are only reset on genuine header width shrinks and only when a group truly has no active panel, preventing blank DockView content on visibility/maximize transitions.

Sequence diagram for guarded maximize exit behavior

sequenceDiagram
    participant Dockview
    participant Gridview
    participant DockviewParams as DockviewParams

    Dockview->>Dockview: cerateDockview
    Dockview->>Dockview: guardMaximizeExit
    Dockview->>Gridview: wrap exitMaximizedView

    Gridview->>Gridview: exitMaximizedView
    Gridview->>DockviewParams: set maximizing = true
    Gridview->>Gridview: original exitMaximizedView
    Gridview->>DockviewParams: restore maximizing
Loading

Flow diagram for setWidth active panel handling on shrink

flowchart TD
    A[setWidth] --> B[find group for header]
    B --> C[update _lastHeaderWidth]
    C --> D{voidWidth == 0?}
    D -->|no| H
    D -->|yes| E{tabs > 1?}
    E -->|no| H
    E -->|yes| F{shrinking and active tab would overflow?}
    F -->|yes| G[call group.panels_0_.api.setActive]
    F -->|no| H[adjust tabs into dropdown]
    H --> I{group.activePanel exists?}
    I -->|no| J[call group.panels_0_.api.setActive]
    I -->|yes| K[keep current active panel]
Loading

File-Level Changes

Change Details Files
Guard all gridview maximize exits so the maximizing flag is set consistently, preventing blank restored siblings when leaving maximized state via core operations.
  • Introduce a guardMaximizeExit wrapper that patches the gridview prototype’s exitMaximizedView method once per prototype.
  • Within the wrapper, locate the associated DockView accessor, temporarily set params.maximizing = true for the duration of exitMaximizedView, and restore the previous value afterward.
  • Wire guardMaximizeExit into DockView initialization alongside the existing collapsed-proportions guard.
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js
Tighten tab header width handling so the active panel is only re-picked on actual shrinks and only when there is no active panel, avoiding unwanted switches and blank content after hidden views become visible.
  • Track the last known header width per group (_lastHeaderWidth) and compute a shrinking flag when the header width strictly decreases.
  • On shrink with overflow, proactively activate the first panel if the currently active tab would overflow into the dropdown, switching before it is hidden.
  • Replace the prior "no active tab in visible strip" fallback with a simpler check that the group exists and has no activePanel, then activate the first panel as a true fallback.
  • Ensure the early return when there is only one tab remains and reuse the computed group object throughout setWidth.
src/components/BootstrapBlazor.DockView/wwwroot/js/dockview-utils.js

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

@bb-auto bb-auto Bot requested a review from ArgoZhang June 23, 2026 11:31

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In guardMaximizeExit, consider defensively checking that proto.exitMaximizedView exists before wrapping it so the guard degrades gracefully if the underlying gridview implementation changes.
  • The _lastHeaderWidth state is being attached ad hoc to the group object; it may be safer to centralize this tracking (or ensure it’s cleared on group disposal) to avoid stale width data if groups/headers are recycled.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `guardMaximizeExit`, consider defensively checking that `proto.exitMaximizedView` exists before wrapping it so the guard degrades gracefully if the underlying gridview implementation changes.
- The `_lastHeaderWidth` state is being attached ad hoc to the group object; it may be safer to centralize this tracking (or ensure it’s cleared on group disposal) to avoid stale width data if groups/headers are recycled.

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.

@ArgoZhang ArgoZhang changed the title fix(DockView): active-panel reset on becoming visible + blank siblings on exit-maximize fix(DockView): stop sibling blanking on any exit-maximize Jun 24, 2026
@bb-auto bb-auto Bot added the enhancement New feature or request label Jun 24, 2026
@bb-auto bb-auto Bot added this to the v10.0.0 milestone Jun 24, 2026
@ArgoZhang ArgoZhang merged commit 5ddd616 into master Jun 24, 2026
3 checks passed
@ArgoZhang ArgoZhang deleted the fix-dockview branch June 24, 2026 00:39
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.

bug(DockView): stop sibling blanking on any exit-maximize

2 participants