Merge pull request #755 from nyakang/fix/issue-754-empty-activity-bar
fix(activity-bar): hide empty sidebar after hidden items
This commit is contained in:
3 files changed
+27
-8
No files matched your search
@@ -36,6 +36,7 @@ import QuickCommands from "@/components/panel/QuickCommands";
|
||||
import SerialSendPanel from "@/components/panel/SendCommandPanel";
|
||||
import TabWindowsWorkspace from "@/components/terminal/TabWindowsWorkspace";
|
||||
import { useTheme } from "@/context/ThemeContext";
|
||||
import { hasVisibleActivityBarItems } from "@/lib/appWorkspace";
|
||||
import {
|
||||
buildBackgroundImageLayerStyle,
|
||||
buildSurfaceCssVariables,
|
||||
@@ -246,14 +247,8 @@ export default function AppLayout({
|
||||
}),
|
||||
[effectiveAppearance, theme.colors, windowTransparencyEnabled],
|
||||
);
|
||||
const hasLeftActivityItems =
|
||||
leftActivityBar.items.length > 0 ||
|
||||
(leftActivityBar.bottomItems?.length ?? 0) > 0 ||
|
||||
(leftActivityBar.hiddenItems?.length ?? 0) > 0;
|
||||
const hasRightActivityItems =
|
||||
rightActivityBar.items.length > 0 ||
|
||||
(rightActivityBar.bottomItems?.length ?? 0) > 0 ||
|
||||
(rightActivityBar.hiddenItems?.length ?? 0) > 0;
|
||||
const hasLeftActivityItems = hasVisibleActivityBarItems(leftActivityBar);
|
||||
const hasRightActivityItems = hasVisibleActivityBarItems(rightActivityBar);
|
||||
const leftPanelOpen =
|
||||
hasLeftActivityItems &&
|
||||
(leftPanelIds.length > 0 || Boolean(leftOverlayPanelId));
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
getItemSide,
|
||||
getSideOpenPanels,
|
||||
getVisibleActivityIds,
|
||||
hasVisibleActivityBarItems,
|
||||
hideActivityBarItem,
|
||||
isActivityBarItemVisible,
|
||||
isActivityItemAvailable,
|
||||
@@ -133,6 +134,18 @@ function uiConfig(overrides: Partial<UiConfig> = {}): UiConfig {
|
||||
}
|
||||
|
||||
describe("activity bar visibility state", () => {
|
||||
it("does not keep a side visible when it only contains hidden items", () => {
|
||||
expect(
|
||||
hasVisibleActivityBarItems({
|
||||
items: [],
|
||||
bottomItems: [],
|
||||
hiddenItems: ["fileExplorer"],
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(hasVisibleActivityBarItems({ items: ["savedConnections"] })).toBe(true);
|
||||
expect(hasVisibleActivityBarItems({ items: [], bottomItems: ["settings"] })).toBe(true);
|
||||
});
|
||||
|
||||
it("hides, shows, and toggles icons without changing feature availability", () => {
|
||||
const ui = uiConfig({
|
||||
show_gpu_monitor: true,
|
||||
|
||||
@@ -228,6 +228,17 @@ export function getVisibleActivityIds(ids: string[], ui: UiConfig): string[] {
|
||||
return ids.filter((id) => isActivityBarItemVisible(id, ui));
|
||||
}
|
||||
|
||||
export function hasVisibleActivityBarItems({
|
||||
items,
|
||||
bottomItems,
|
||||
}: {
|
||||
items: readonly unknown[];
|
||||
bottomItems?: readonly unknown[];
|
||||
hiddenItems?: readonly unknown[];
|
||||
}): boolean {
|
||||
return items.length > 0 || (bottomItems?.length ?? 0) > 0;
|
||||
}
|
||||
|
||||
export function cloneDefaultActivityBarLayout(): ActivityBarLayout {
|
||||
return {
|
||||
left_top: [...DEFAULT_ACTIVITY_BAR_LAYOUT.left_top],
|
||||
|
||||
Reference in new issue
Block a user