Skip to content

Conversation

@ThanhNguyxn
Copy link
Contributor

Summary

This PR fixes a bug where the panel doesn't close when clicking the toggle button while the panel is maximized and center-aligned.

Problem

When the panel is in "center" alignment mode and maximized, clicking the toggle panel button fails to close the panel. The issue occurs because the focusGroup parameter is undefined when trying to read activeElement property.

Fixes #281772

Solution

Added a null check to safely access focusGroup?.activeElement instead of directly accessing focusGroup.activeElement, preventing the runtime error and allowing the panel to close correctly.

Testing

  • Tested with panel in center alignment mode
  • Maximized the panel
  • Verified toggle button now correctly closes the panel

Copilot AI review requested due to automatic review settings December 7, 2025 11:55
@vs-code-engineering
Copy link

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/workbench/browser/layout.ts

Copy link
Contributor

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

This PR fixes a bug where the panel fails to close when clicking the toggle button while the panel is maximized and center-aligned. The issue stems from a circular dependency in the layout state management.

Key changes:

  • Moved the unmaximize logic to execute before changing the panel's visibility state
  • Updated comment to reflect the actual reason for the change (preventing conflict with setEditorHidden)

Comment on lines +1958 to +1959
// changing visibility to prevent conflict with setEditorHidden
// which would force panel visible again (fixes #281772)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment mentions "prevent conflict with setEditorHidden" but could be clearer. The conflict occurs because toggleMaximizedPanel() calls setEditorHidden(false) (at line 2126), which then checks if both editor and panel are hidden (at line 1798), and if so, forces the panel visible again via setPanelHidden(false, true) (at line 1799). By calling toggleMaximizedPanel() before changing the panel's hidden state, the panel is still visible when setEditorHidden checks, avoiding the forced re-showing. Consider clarifying this chain of events in the comment.

Suggested change
// changing visibility to prevent conflict with setEditorHidden
// which would force panel visible again (fixes #281772)
// changing visibility. This prevents a conflict with setEditorHidden:
// toggleMaximizedPanel() calls setEditorHidden(false), which checks if both editor and panel are hidden,
// and if so, forces the panel visible again via setPanelHidden(false, true).
// By unmaximizing before hiding, the panel is still visible when setEditorHidden checks,
// so it does not force the panel to be shown again. (fixes #281772)

Copilot uses AI. Check for mistakes.
@joaomoreno
Copy link
Member

Thank you! 🍻

@joaomoreno joaomoreno added the bug Issue identified by VS Code Team member as probable bug label Dec 8, 2025
@joaomoreno joaomoreno merged commit b1f22b8 into microsoft:main Dec 8, 2025
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ctrl+J (togglePanel) doesn't close panel when maximized and center-aligned

3 participants