Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): keep the sidebar tabs clear of the pin/close buttons (closes #11097)

Elian Doranda072785a135
diff --git a/apps/client/src/widgets/sidebar/RightPaneTabs.css b/apps/client/src/widgets/sidebar/RightPaneTabs.css
deleted file mode 100644
index 4f519c06ac..0000000000
--- a/apps/client/src/widgets/sidebar/RightPaneTabs.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * The tab strip is also the pane's header row: the pin/close actions are absolutely positioned over its
- * end (see RightPanelContainer.css), and as much room again is kept free at the start, so the group is
- * centred in the pane rather than in what is left of the row.
- *
- * Everything the strip itself is — the centring, the group, the size of a tab — is shared with the other
- * strips (see TabStrip.css); what is left here is the row it is given to head.
- */
-.right-pane-tabs {
- height: var(--right-pane-header-height);
- padding-inline: 50px;
- border-bottom: 1px solid var(--main-border-color);
-}
diff --git a/apps/client/src/widgets/sidebar/RightPaneTabs.tsx b/apps/client/src/widgets/sidebar/RightPaneTabs.tsx
index f4e3dc9e2d..25c24bb57d 100644
--- a/apps/client/src/widgets/sidebar/RightPaneTabs.tsx
+++ b/apps/client/src/widgets/sidebar/RightPaneTabs.tsx
@@ -1,5 +1,3 @@
-import "./RightPaneTabs.css";
-
import { t } from "../../services/i18n";
import TabStrip, { type TabStripTabDefinition } from "../react/TabStrip";
@@ -40,9 +38,8 @@ interface RightPaneTabsProps {
}
/**
- * The right pane's header: which group of widgets is on show. It doubles as the row the pane's own
- * pin/close actions sit in, so it is rendered whenever the pane is open — which is what the row it
- * hands the shared strip is for (see RightPaneTabs.css).
+ * The tab strip of the right pane's header row: which group of widgets is on show. RightPanelContainer
+ * lays it out beside the pane's pin/close actions (see RightPanelContainer.css).
*/
export default function RightPaneTabs({ tabs, activeTabId, onSelect }: RightPaneTabsProps) {
return (
diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.css b/apps/client/src/widgets/sidebar/RightPanelContainer.css
index ed2ec8c9cc..de8f083f6a 100644
--- a/apps/client/src/widgets/sidebar/RightPanelContainer.css
+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.css
@@ -92,28 +92,11 @@ body.experimental-feature-new-layout #right-pane-host.peek > .right-pane-peek-sp
min-width: 0;
}
-/* Pin/close controls, shown whenever the pane is open (pin only in peek mode). */
-body.experimental-feature-new-layout #right-pane .right-pane-actions {
- --icon-button-size: 24px;
-
- position: absolute;
- top: 0;
- right: 0;
- width: 80px;
- height: var(--right-pane-header-height);
- z-index: 1;
- display: flex;
- gap: 2px;
- align-items: center;
- justify-content: flex-end;
-}
-
body.experimental-feature-new-layout #right-pane {
- position: relative;
display: flex;
flex-direction: column;
- /* The scrolling belongs to the shown tab's body rather than to the pane, which would carry the tab
- strip (and the actions overlaying it) off the top with it. */
+ /* The scrolling belongs to the shown tab's body rather than to the pane, which would carry the
+ header row off the top with it. */
overflow: hidden;
&.right-pane-mode-peek {
@@ -122,6 +105,46 @@ body.experimental-feature-new-layout #right-pane {
border-radius: var(--right-pane-peek-border-radius);
}
+ /* The pane's header row: the tab strip and the pin/close actions laid out together, so a narrow
+ pane shrinks the strip instead of sliding it under the buttons. */
+ .right-pane-header {
+ display: flex;
+ align-items: center;
+ flex-shrink: 0;
+ height: var(--right-pane-header-height);
+ border-bottom: 1px solid var(--main-border-color);
+
+ /* Counterweight to `.right-pane-actions` at the other end: both sides flex alike, so the
+ strip centres on the pane rather than in the space the actions leave over. */
+ &::before {
+ content: "";
+ flex: 1 1 0;
+ }
+
+ > .right-pane-tabs {
+ /* Overrides the `flex-shrink: 0` the strip carries for hosts that give it a row of its
+ own (see TabStrip.css): here the strip is what gives way — scrolling within itself —
+ once both of its flanks are at their minimum. */
+ flex: 0 1 auto;
+ min-width: 0;
+ align-self: stretch;
+ }
+
+ /* Pin/close controls, shown whenever the pane is open (pin only in peek mode). */
+ > .right-pane-actions {
+ --icon-button-size: 24px;
+
+ display: flex;
+ gap: 2px;
+ align-items: center;
+ justify-content: flex-end;
+ flex: 1 1 0;
+ /* The flexible share is given up before the buttons are: they stay whole and pressable
+ at any pane width. */
+ min-width: max-content;
+ }
+ }
+
.card {
margin-inline: 0;
border-bottom: 1px solid var(--main-border-color);
@@ -205,8 +228,7 @@ body.experimental-feature-new-layout #right-pane {
overflow-y: auto;
}
- /* The strip is what the pane's actions overlay, so the cards no longer make room for them (the
- first card's header used to be what they sat over); it sits right under the strip's border. */
+ /* The first card sits right under the header row's border, which separates them already. */
.right-pane-tab-body > .card:first-child .card-header {
padding-top: 0;
}
diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
index f01f866bbf..89a2c7251c 100644
--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
@@ -134,23 +134,27 @@ export default function RightPanelContainer({ widgetsByParent }: { widgetsByPare
<div class="right-pane-peek-spacer" />
{/* Mode class (right-pane-mode-docked / -peek) as a styling hook; none when closed. */}
<div id="right-pane" class={visible ? `right-pane-mode-${mode}` : undefined}>
- {visible && (
- <div class="right-pane-actions">
- {/* Pin only applies while peeking (it docks the pane); close shows in both modes. */}
- {mode === "peek" && <ActionButton icon="bx bx-pin" text={t("right_pane.dock")} onClick={dock} />}
- <ActionButton icon="bx bx-x" text={t("right_pane.close")} onClick={close} />
- </div>
- )}
{mounted && (
- tabs.length > 0 ? (
- <>
- <RightPaneTabs
- tabs={tabs}
- activeTabId={activeTab?.id}
- onSelect={(tabId) => void setSelectedTabId(tabId)}
- />
-
- {tabs.filter((tab) => openedTabs.current.has(tab.id)).map((tab) => (
+ <>
+ {/* One flex row holding the tab strip and the pane's own actions, so a
+ narrow pane shrinks the strip instead of sliding it under the buttons
+ (see RightPanelContainer.css). */}
+ <div class="right-pane-header">
+ {tabs.length > 0 && (
+ <RightPaneTabs
+ tabs={tabs}
+ activeTabId={activeTab?.id}
+ onSelect={(tabId) => void setSelectedTabId(tabId)}
+ />
+ )}
+ <div class="right-pane-actions">
+ {/* Pin only applies while peeking (it docks the pane); close shows in both modes. */}
+ {mode === "peek" && <ActionButton icon="bx bx-pin" text={t("right_pane.dock")} onClick={dock} />}
+ <ActionButton icon="bx bx-x" text={t("right_pane.close")} onClick={close} />
+ </div>
+ </div>
+ {tabs.length > 0 ? (
+ tabs.filter((tab) => openedTabs.current.has(tab.id)).map((tab) => (
<div
key={tab.id}
role="tabpanel"
@@ -168,22 +172,22 @@ export default function RightPanelContainer({ widgetsByParent }: { widgetsByPare
</ExpandWidgetRequests.Provider>
</CollapsibleWidgets.Provider>
</div>
- ))}
- </>
- ) : (
- <NoItems
- icon="bx bx-sidebar"
- text={t("right_pane.empty_message")}
- >
- {/* The peek auto-closes (outside click / focus loss / Esc), so a manual hide button is redundant there. */}
- {mode !== "peek" && (
- <Button
- text={t("right_pane.empty_button")}
- triggerCommand="toggleRightPane"
- />
- )}
- </NoItems>
- )
+ ))
+ ) : (
+ <NoItems
+ icon="bx bx-sidebar"
+ text={t("right_pane.empty_message")}
+ >
+ {/* The peek auto-closes (outside click / focus loss / Esc), so a manual hide button is redundant there. */}
+ {mode !== "peek" && (
+ <Button
+ text={t("right_pane.empty_button")}
+ triggerCommand="toggleRightPane"
+ />
+ )}
+ </NoItems>
+ )}
+ </>
)}
</div>
</div>