Skip to content

Toolbar - tweak responsive behaviour with new options#276450

Merged
lszomoru merged 3 commits intomainfrom
lszomoru/toolbar-cleaup
Nov 10, 2025
Merged

Toolbar - tweak responsive behaviour with new options#276450
lszomoru merged 3 commits intomainfrom
lszomoru/toolbar-cleaup

Conversation

@lszomoru
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings November 10, 2025 09:58
@lszomoru lszomoru enabled auto-merge (squash) November 10, 2025 09:58
@lszomoru lszomoru self-assigned this Nov 10, 2025
@vs-code-engineering
Copy link

📬 CODENOTIFY

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

@bpasero

Matched files:

  • src/vs/base/browser/ui/toolbar/toolbar.ts

@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 10, 2025
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 refactors the toolbar's responsive behavior by replacing the boolean responsive option with a more granular responsiveBehavior object that includes both an enabled flag and an optional minItems setting. This allows consumers to specify a minimum number of items that should always remain visible in the toolbar.

  • Renamed responsive option to responsiveBehavior with structured configuration
  • Added minItems capability to enforce a minimum number of visible toolbar items
  • Refactored setToolbarMaxWidth to updateActions with improved readability
  • Implemented minimum width calculation based on item count

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/vs/base/browser/ui/toolbar/toolbar.ts Core implementation of the responsive behavior refactoring with new responsiveBehavior API and minimum items logic
src/vs/workbench/contrib/scm/browser/scmRepositoryRenderer.ts Updates SCM repository toolbar to use the new responsiveBehavior API with minItems: 2

// takes precedence over the action label.
return this.actionBar.length() * ACTION_MIN_WIDTH;
}
const actionBarWidth = () => this.actionBar.length() * ACTION_MIN_WIDTH;
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The actionBarWidth function is called multiple times in conditional checks and loops within the same method (lines 292, 296, 309, 338). Consider computing the value once and reusing it, or storing it in a variable that's updated when this.actionBar.length() changes to avoid redundant calculations.

Copilot uses AI. Check for mistakes.
Comment on lines +258 to +259
this.container.style.minWidth = `${itemCount * ACTION_MIN_WIDTH}px`;
this.element.style.minWidth = `${itemCount * ACTION_MIN_WIDTH}px`;
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The minimum width calculation itemCount * ACTION_MIN_WIDTH is duplicated on lines 258 and 259. Consider extracting this to a local variable to reduce duplication and improve maintainability.

Suggested change
this.container.style.minWidth = `${itemCount * ACTION_MIN_WIDTH}px`;
this.element.style.minWidth = `${itemCount * ACTION_MIN_WIDTH}px`;
const minWidthPx = `${itemCount * ACTION_MIN_WIDTH}px`;
this.container.style.minWidth = minWidthPx;
this.element.style.minWidth = minWidthPx;

Copilot uses AI. Check for mistakes.
@lszomoru lszomoru merged commit 16cfd3b into main Nov 10, 2025
33 of 34 checks passed
@lszomoru lszomoru deleted the lszomoru/toolbar-cleaup branch November 10, 2025 10:17
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants