Skip to content

feat: add experimental option for sidebar auto-centering#612

Merged
metastable-void merged 1 commit intomenhera-org:mainfrom
hajimemanila:feature/add-sidebar-centering-toggle
Feb 17, 2026
Merged

feat: add experimental option for sidebar auto-centering#612
metastable-void merged 1 commit intomenhera-org:mainfrom
hajimemanila:feature/add-sidebar-centering-toggle

Conversation

@hajimemanila
Copy link

Description

This PR adds an experimental option to toggle the auto-centering behavior in the sidebar panel.

Following the recent change (commit e41d14d), the sidebar no longer auto-scrolls to the active tab. While this provides great operational stability for many, some power users with high tab counts still prefer the auto-centering navigation in the sidebar.

Key Changes

  • New Setting: Added Auto-center active tab in sidebar under "Experimental Features" (disabled by default).
  • Adaptive Logic: Refactored menulist-tab.ts to respect both the popup context and the user's preference.
  • Backward Compatibility: Maintained the existing behavior for the toolbar popup.

Verification

  • Verified that the sidebar stays stationary when the option is OFF.
  • Verified that the sidebar auto-centers when the option is ON.
  • Verified that the popup always auto-centers regardless of the setting.

Reference:
I shared some thoughts on why this toggle is beneficial for power users here:
[URL_OF_MY_COMMENT]

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

This PR adds an experimental configuration option to enable auto-centering of the active tab in the sidebar panel. Previously, the sidebar auto-scrolling behavior was removed (commit e41d14d), but this PR provides a toggle to restore that functionality for users who prefer it.

Changes:

  • Added new configuration option tab.autoCenterInSidebar (disabled by default) under experimental features
  • Modified scrolling logic in menulist-tab.ts to check both popup context and user preference
  • Added UI elements and localization for the new option

Reviewed changes

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

Show a summary per file
File Description
src/config/config.ts Added new boolean configuration option tab.autoCenterInSidebar with default value false
src/components/menulist-tab.ts Refactored scrollIntoViewIfActive() to check both popup context and user preference before auto-scrolling
src/pages/options/options.html Added checkbox input for the new auto-center option in experimental features section
src/pages/options/options.ts Added event handlers and observers for the new configuration option
src/pages/options/options-i18n.ts Added localization setup for the new option label
static/_locales/en/messages.json Added English translation string for the new option

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

Comment on lines +141 to 151
private async scrollIntoViewIfActive(): Promise<void> {
const isPopup = document.body.classList.contains('popup');
const autoCenter = await config['tab.autoCenterInSidebar'].getValue();
if (isPopup || autoCenter) {
// Scroll the active tab into view at the center of the sidebar
// Using requestAnimationFrame to ensure DOM is ready
requestAnimationFrame(() => {
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
});
}
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

This async function call on every tab render creates unnecessary performance overhead. The config value is cached by StorageConfigurationOption after the first access, so you should use the synchronous tryGetValueSync() method instead. This is particularly important since this code path is triggered for every active tab during rendering. Consider this pattern used elsewhere in the codebase (e.g., panel-windows.ts line 96):

private scrollIntoViewIfActive(): void {
  const isPopup = document.body.classList.contains('popup');
  const autoCenter = config['tab.autoCenterInSidebar'].tryGetValueSync() ?? false;
  if (isPopup || autoCenter) {
    requestAnimationFrame(() => {
      this.scrollIntoView({ behavior: 'smooth', block: 'center' });
    });
  }
}

The cached value will be available after the config is initialized, and the default value of false is safe to use as a fallback.

Copilot uses AI. Check for mistakes.
@metastable-void metastable-void added this pull request to the merge queue Feb 17, 2026
Merged via the queue into menhera-org:main with commit c298c01 Feb 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments