Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Keep hidden dock bars floating and accessible https://github.com/siyuan-note/siyuan/issues/20833

Daniel3794eb31e55c
diff --git a/app/src/assets/scss/business/_layout.scss b/app/src/assets/scss/business/_layout.scss
index 0e1cc3e773..aedb14cac3 100644
--- a/app/src/assets/scss/business/_layout.scss
+++ b/app/src/assets/scss/business/_layout.scss
@@ -435,6 +435,18 @@
overscroll-behavior-y: contain;
scrollbar-width: none;
+ &--float {
+ position: fixed;
+ left: 0;
+ height: auto;
+ background-color: var(--b3-body-background);
+
+ &#dockRight {
+ left: auto;
+ right: 0;
+ }
+ }
+
&::-webkit-scrollbar {
display: none;
}
diff --git a/app/src/assets/scss/util/_reset.scss b/app/src/assets/scss/util/_reset.scss
index 800a76c086..79b3bd75f4 100644
--- a/app/src/assets/scss/util/_reset.scss
+++ b/app/src/assets/scss/util/_reset.scss
@@ -158,8 +158,11 @@ body {
&.body--toolbar-hide {
#dockLeft, #dockRight {
- height: calc(100% - var(--b3-ui-panel-height, 42px));
margin-top: var(--b3-ui-panel-height, 42px);
+
+ &:not(.dock--float) {
+ height: calc(100% - var(--b3-ui-panel-height, 42px));
+ }
}
.toolbar {
diff --git a/app/src/boot/globalEvent/mousemove.ts b/app/src/boot/globalEvent/mousemove.ts
index be18bb6431..a0cf4095ec 100644
--- a/app/src/boot/globalEvent/mousemove.ts
+++ b/app/src/boot/globalEvent/mousemove.ts
@@ -110,8 +110,9 @@ export const windowMouseMove = (event: MouseEvent) => {
!hasClosestByClassName(target, "protyle-util");
const leftDock = window.siyuan.layout.leftDock;
const leftBar = document.getElementById("dockLeft");
- const leftBarWidth = leftBar.clientWidth;
- const leftTrigger = canTrigger && inYRange && leftDock.isFloating() && leftDock.layout.element.clientWidth > 0 &&
+ const leftBarWidth = leftBar.classList.contains("dock--float") ? 0 : leftBar.clientWidth;
+ const leftTrigger = canTrigger && inYRange && leftDock.isFloating() &&
+ (leftDock.layout.element.clientWidth > 0 || window.siyuan.config.uiLayout.hideDock) &&
event.clientX < Math.max(leftBarWidth + 1, 16) &&
// 隐藏停靠栏会导致点击两侧内容触发浮动面板弹出,因此需减小鼠标范围
(leftBarWidth > 0 || event.clientX < 8);
@@ -123,8 +124,9 @@ export const windowMouseMove = (event: MouseEvent) => {
const rightDock = window.siyuan.layout.rightDock;
const rightBar = document.getElementById("dockRight");
- const rightBarWidth = rightBar.clientWidth;
- const rightTrigger = canTrigger && inYRange && rightDock.isFloating() && rightDock.layout.element.clientWidth > 0 &&
+ const rightBarWidth = rightBar.classList.contains("dock--float") ? 0 : rightBar.clientWidth;
+ const rightTrigger = canTrigger && inYRange && rightDock.isFloating() &&
+ (rightDock.layout.element.clientWidth > 0 || window.siyuan.config.uiLayout.hideDock) &&
event.clientX > window.innerWidth - Math.max(rightBarWidth - 2, 16) &&
(rightBarWidth > 0 || event.clientX > window.innerWidth - 8);
if (rightTrigger || rightDock.layout.element.contains(target) || rightBar.contains(target)) {
diff --git a/app/src/layout/dock/barVisibility.test.ts b/app/src/layout/dock/barVisibility.test.ts
index 39b449db95..5d7fd7fad2 100644
--- a/app/src/layout/dock/barVisibility.test.ts
+++ b/app/src/layout/dock/barVisibility.test.ts
@@ -49,6 +49,18 @@ describe("dock padding", () => {
loadBarVisibility(layout).adjustDockPadding();
assert.deepEqual(style, {marginLeft: "", marginRight: "", marginBottom: ""});
});
+
+ it("preserves hidden-dock padding while a temporary dock bar overlays the editor", () => {
+ const style = {marginLeft: "", marginRight: "", marginBottom: ""};
+ const floatingBar = {classList: {contains: (name: string) => name === "dock--float"}};
+ const layout = {
+ layout: {children: [{element: {style}}]},
+ leftDock: {elements: [{parentElement: floatingBar}]},
+ rightDock: {elements: [{parentElement: floatingBar}]},
+ };
+ loadBarVisibility(layout).adjustDockPadding();
+ assert.deepEqual(style, {marginLeft: "var(--b3-layout-space)", marginRight: "var(--b3-layout-space)", marginBottom: ""});
+ });
});
describe("dock bar visibility", () => {
@@ -65,7 +77,7 @@ describe("dock bar visibility", () => {
assert.equal(shouldShowDockBar(true, false), false);
});
- it("temporarily shows a non-empty dock bar for an expanded floating panel", () => {
+ it("temporarily shows non-empty dock bars for a floating panel or edge hover", () => {
assert.equal(shouldShowDockBar(true, true, true), true);
assert.equal(shouldShowDockBar(true, false, true), false);
assert.equal(shouldShowDockBar(false, true, true), true);
diff --git a/app/src/layout/dock/barVisibility.ts b/app/src/layout/dock/barVisibility.ts
index 0fc647ac2c..6cbd73d295 100644
--- a/app/src/layout/dock/barVisibility.ts
+++ b/app/src/layout/dock/barVisibility.ts
@@ -1,9 +1,12 @@
-export const shouldShowDockBar = (globallyHidden: boolean, hasVisibleEntry: boolean, floatingPanelOpen = false) =>
- (!globallyHidden || floatingPanelOpen) && hasVisibleEntry;
+export const shouldShowDockBar = (globallyHidden: boolean, hasVisibleEntry: boolean, temporarilyShown = false) =>
+ (!globallyHidden || temporarilyShown) && hasVisibleEntry;
export const shouldShowDockSplit = (hasVisibleEntryBefore: boolean, hasVisibleEntryAfter: boolean) =>
hasVisibleEntryBefore && hasVisibleEntryAfter;
+const hoveredDockBars = new WeakSet<HTMLElement>();
+let floatingBarResizeObserver: ResizeObserver;
+
export const adjustDockPadding = () => {
const layoutElement = window.siyuan.layout?.layout?.children[0]?.element;
const leftDockElement = window.siyuan.layout?.leftDock?.elements[0]?.parentElement;
@@ -12,12 +15,12 @@ export const adjustDockPadding = () => {
if (!layoutElement || !leftDockElement || !rightDockElement) {
return;
}
- if (leftDockElement.classList.contains("fn__none")) {
+ if (leftDockElement.classList.contains("fn__none") || leftDockElement.classList.contains("dock--float")) {
layoutElement.style.marginLeft = "var(--b3-layout-space)";
} else {
layoutElement.style.marginLeft = "";
}
- if (rightDockElement.classList.contains("fn__none")) {
+ if (rightDockElement.classList.contains("fn__none") || rightDockElement.classList.contains("dock--float")) {
layoutElement.style.marginRight = "var(--b3-layout-space)";
} else {
layoutElement.style.marginRight = "";
@@ -31,6 +34,7 @@ export const adjustDockPadding = () => {
export const syncDockBarVisibility = () => {
let changed = false;
+ let hasFloatingBar = false;
document.querySelectorAll<HTMLElement>(".dock").forEach((item) => {
const sections = Array.from(item.querySelectorAll<HTMLElement>(":scope > .dock__items"));
const sectionVisibility = sections.map((section) =>
@@ -44,14 +48,62 @@ export const syncDockBarVisibility = () => {
item.id === "dockRight" ? window.siyuan.layout?.rightDock : undefined;
const floatingPanelOpen = Boolean(dock?.isFloating() && dock.isPanelVisible() &&
!dock.layout.element.classList.contains("fn__none") && dock.layout.element.style.opacity === "1");
+ const canFloat = window.siyuan.config.uiLayout.hideDock && dock?.isFloating() && sectionVisibility.some(Boolean);
+ if (!canFloat) {
+ hoveredDockBars.delete(item);
+ }
+ const floating = Boolean(canFloat && (floatingPanelOpen || hoveredDockBars.has(item)));
+ const wasFloating = item.classList.contains("dock--float");
+ item.classList.toggle("dock--float", floating);
const hidden = !shouldShowDockBar(
window.siyuan.config.uiLayout.hideDock,
sectionVisibility.some(Boolean),
- floatingPanelOpen,
+ floating,
);
- changed = item.classList.contains("fn__none") !== hidden || changed;
+ changed = item.classList.contains("fn__none") !== hidden || wasFloating !== floating || changed;
item.classList.toggle("fn__none", hidden);
+ if (floating) {
+ hasFloatingBar = true;
+ // 保留停靠栏原有的顶栏避让和高度范围,临时显示时脱离编辑区布局。
+ const rowRect = item.parentElement.getBoundingClientRect();
+ item.style.top = rowRect.top + "px";
+ item.style.bottom = (window.innerHeight - rowRect.bottom) + "px";
+ item.style.zIndex = (Math.max(10, Number(dock.layout.element.style.zIndex)) - 1).toString();
+ } else if (wasFloating) {
+ item.style.top = "";
+ item.style.bottom = "";
+ item.style.zIndex = "";
+ }
});
adjustDockPadding();
+ if (hasFloatingBar && !floatingBarResizeObserver) {
+ floatingBarResizeObserver = new ResizeObserver(() => {
+ syncDockBarVisibility();
+ for (const dock of [window.siyuan.layout?.leftDock, window.siyuan.layout?.rightDock]) {
+ if (dock?.elements[0].parentElement.classList.contains("dock--float") &&
+ dock.isPanelVisible() && dock.layout.element.style.opacity === "1") {
+ dock.showDock(true);
+ }
+ }
+ });
+ for (const element of [document.getElementById("dockLeft"), document.getElementById("dockRight")]) {
+ if (element) {
+ floatingBarResizeObserver.observe(element);
+ floatingBarResizeObserver.observe(element.parentElement);
+ }
+ }
+ } else if (!hasFloatingBar && floatingBarResizeObserver) {
+ floatingBarResizeObserver.disconnect();
+ floatingBarResizeObserver = undefined;
+ }
return changed;
};
+
+export const setDockBarHover = (element: HTMLElement, hovered: boolean) => {
+ if (hovered) {
+ hoveredDockBars.add(element);
+ } else {
+ hoveredDockBars.delete(element);
+ }
+ syncDockBarVisibility();
+};
diff --git a/app/src/layout/dock/index.test.ts b/app/src/layout/dock/index.test.ts
index 4e3006618a..295abad06f 100644
--- a/app/src/layout/dock/index.test.ts
+++ b/app/src/layout/dock/index.test.ts
@@ -42,7 +42,7 @@ const loadDockPrototype = (frames: Array<() => void>, document: object, adjustLa
return {bindPanelTransitionGuard() {}};
}
if (name.endsWith("/barVisibility")) {
- return {syncDockBarVisibility() {}};
+ return {syncDockBarVisibility() {}, setDockBarHover() {}};
}
return {};
},
diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.ts
index 03952aaa9d..0f38be13aa 100644
--- a/app/src/layout/dock/index.ts
+++ b/app/src/layout/dock/index.ts
@@ -34,7 +34,7 @@ import {syncDockEntryOrders} from "../../config/entryVisibility/runtime";
import {isWindow} from "../../util/functions";
import {bindPanelTransitionGuard} from "../../util/panelTransition";
import {isTouchHoverInput} from "../../util/hoverInput";
-import {syncDockBarVisibility} from "./barVisibility";
+import {setDockBarHover, syncDockBarVisibility} from "./barVisibility";
const TYPES = ["file", "outline", "inbox", "bookmark", "tag", "graph", "globalGraph", "backlink", "agentChat"];
const DEFAULT_DOCK_SIZE = 232;
@@ -423,7 +423,7 @@ export class Dock {
this.collapsedPanelSize = "";
this.layout.element.classList.remove("fn__none");
this.resizeElement.classList.add("fn__none");
- this.syncDockBar();
+ syncDockBarVisibility();
return false;
}
@@ -457,6 +457,9 @@ export class Dock {
}
if (!resolution.visible) {
this.clearDockHoverTimeout();
+ if (this.position === "Left" || this.position === "Right") {
+ setDockBarHover(this.elements[0].parentElement, false);
+ }
window.clearTimeout(this.hideResizeTimeout);
if (document.activeElement && this.layout.element.contains(document.activeElement)) {
(document.activeElement as HTMLElement).blur();
@@ -475,7 +478,7 @@ export class Dock {
}
}
}
- this.syncDockBar();
+ syncDockBarVisibility();
resizeTabs(false);
setTabPosition(true);
if (resolution.visible) {
@@ -525,7 +528,7 @@ export class Dock {
if (!hasActive && !this.isFloating()) {
this.layout.element.style[this.position === "Bottom" ? "height" : "width"] = "0px";
}
- this.syncDockBar();
+ syncDockBarVisibility();
resizeTabs(isSaveLayout);
setTabPosition(true);
}
@@ -557,12 +560,18 @@ export class Dock {
public showDockByHover() {
window.clearTimeout(this.hideDockTimeout);
this.hideDockTimeout = 0;
- if (isTouchHoverInput() || !this.panelVisible || this.showDockTimeout || !this.isFloating() ||
- this.layout.element.style.opacity === "1") {
+ const canRevealBar = (this.position === "Left" || this.position === "Right") && window.siyuan.config.uiLayout.hideDock;
+ const needsBar = canRevealBar && !this.elements[0].parentElement.classList.contains("dock--float");
+ if (isTouchHoverInput() || this.showDockTimeout || !this.isFloating() ||
+ !needsBar && (!this.panelVisible || this.layout.element.style.opacity === "1" || canRevealBar && !this.hasActive())) {
return;
}
this.showDockTimeout = window.setTimeout(() => {
this.showDockTimeout = 0;
+ if (canRevealBar && window.siyuan.config.uiLayout.hideDock && this.isFloating()) {
+ this.layout.element.style.zIndex = (++window.siyuan.zIndex).toString();
+ setDockBarHover(this.elements[0].parentElement, true);
+ }
this.showDock();
}, Constants.TIMEOUT_DOCK_TOGGLE);
}
@@ -570,8 +579,10 @@ export class Dock {
public hideDockByHover() {
window.clearTimeout(this.showDockTimeout);
this.showDockTimeout = 0;
- if (isTouchHoverInput() || !this.panelVisible || this.hideDockTimeout || !this.isFloating() ||
- this.layout.element.style.opacity === "0") {
+ const barVisible = (this.position === "Left" || this.position === "Right") &&
+ this.elements[0].parentElement.classList.contains("dock--float");
+ if (isTouchHoverInput() || this.hideDockTimeout || !this.isFloating() ||
+ !barVisible && (!this.panelVisible || this.layout.element.style.opacity === "0")) {
return;
}
this.hideDockTimeout = window.setTimeout(() => {
@@ -587,21 +598,10 @@ export class Dock {
this.hideDockTimeout = 0;
}
- private syncDockBar() {
- if (!syncDockBarVisibility()) {
- return;
- }
- // 临时显示停靠栏时沿用正常占位,并同步编辑区和已展开的底部面板。
- resizeTabs(false);
- setTabPosition(true);
- const bottomDock = window.siyuan.layout.bottomDock;
- if (this.position !== "Bottom" && bottomDock?.isFloating() && bottomDock.layout.element.style.opacity === "1") {
- bottomDock.showDock(true);
- }
- }
-
public showDock(reset = false) {
- this.clearDockHoverTimeout();
+ if (!reset) {
+ this.clearDockHoverTimeout();
+ }
if (this.initializing || !this.panelVisible || (!reset && (!this.isFloating() || this.layout.element.style.opacity === "1")) ||
(!this.elements[0].querySelector(".dock__item--active") && !this.elements[1].querySelector(".dock__item--active"))
) {
@@ -631,15 +631,15 @@ export class Dock {
this.layout.element.style.opacity = "1";
}
this.layout.element.style.zIndex = (++window.siyuan.zIndex).toString();
- this.syncDockBar();
+ syncDockBarVisibility();
if (this.position === "Left") {
this.layout.element.style.transform = `translateX(${this.elements[0].clientWidth}px)`;
} else if (this.position === "Right") {
this.layout.element.style.transform = `translateX(-${this.elements[0].clientWidth}px)`;
} else if (this.position === "Bottom") {
this.layout.element.style.transform = `translateY(-${document.getElementById("status").offsetHeight}px)`;
- this.layout.element.style.left = this.elements[0].clientWidth + "px";
- this.layout.element.style.right = this.elements[1].clientWidth + "px";
+ this.layout.element.style.left = (window.siyuan.config.uiLayout.hideDock ? 0 : this.elements[0].clientWidth) + "px";
+ this.layout.element.style.right = (window.siyuan.config.uiLayout.hideDock ? 0 : this.elements[1].clientWidth) + "px";
}
// 全屏面板以窗口定位,浮动位移保留到退出全屏时恢复。
const fullscreenElement = this.layout.element.querySelector(".fullscreen");
@@ -658,7 +658,8 @@ export class Dock {
public hideDock(reset = false, preferredSize?: number) {
this.clearDockHoverTimeout();
- if (!reset && (this.layout.element.style.opacity === "0" || !this.isFloating())) {
+ const barVisible = this.position !== "Bottom" && this.elements[0].parentElement.classList.contains("dock--float");
+ if (!reset && (this.layout.element.style.opacity === "0" && !barVisible || !this.isFloating())) {
return;
}
// 关系图全屏不应该退出 & https://github.com/siyuan-note/siyuan/issues/11775
@@ -696,7 +697,11 @@ export class Dock {
this.elements[0].querySelector(".dock__item--activefocus")?.classList.remove("dock__item--activefocus");
this.elements[1].querySelector(".dock__item--activefocus")?.classList.remove("dock__item--activefocus");
this.layout.element.querySelector(".layout__tab--active")?.classList.remove("layout__tab--active");
- this.syncDockBar();
+ if (this.position === "Left" || this.position === "Right") {
+ setDockBarHover(this.elements[0].parentElement, false);
+ } else {
+ syncDockBarVisibility();
+ }
}
public toggleModel(type: TDock | string, show = false, close = false, removeDock = false, isSaveLayout = true,
@@ -1029,7 +1034,7 @@ export class Dock {
anotherWnd.element.style.height = "";
anotherWnd.element.style.width = "";
}
- this.syncDockBar();
+ syncDockBarVisibility();
resizeTabs(isSaveLayout);
if (target.classList.contains("dock__item--active") && !removeDock && this.panelVisible) {
this.showDockAfterResponsiveLayout();
diff --git a/app/tests/dockBarVisibility.test.js b/app/tests/dockBarVisibility.test.js
index f93c8ed24c..6af5289785 100644
--- a/app/tests/dockBarVisibility.test.js
+++ b/app/tests/dockBarVisibility.test.js
@@ -39,13 +39,12 @@ const browserCases = async (sources, css, template) => {
window.siyuan = {zIndex: 10, config: {uiLayout: {hideDock: true}, appearance: {hideStatusBar: false}, system: {os: "linux"}},
layout: {layout: {children: [outer, bottom]}, centerLayout: center}};
const bar = load("barVisibility");
- const resizes = [];
const dependencies = {
...bar, ...load("panelVisibility"),
Constants: {TIMEOUT_DOCK_TOGGLE: 20, TIMEOUT_TRANSITION: 20, ATTRIBUTE_DOCK_WIDTH: "data-width"},
bindPanelTransitionGuard() {}, isTouchHoverInput: () => false,
isWindow: () => false, isAbove: (a, b) => Number(a.style.zIndex) > Number(b.style.zIndex),
- resizeTabs(save) { resizes.push(save); }, setTabPosition() {}, adjustLayout() {}, setPanelFocus() {},
+ resizeTabs() {}, setTabPosition() {}, adjustLayout() {}, setPanelFocus() {},
recordBeforeResizeTop() {}, clearBeforeResizeTop() {},
hasClosestByClassName: (element, name) => element?.closest?.("." + name),
};
@@ -75,7 +74,7 @@ const browserCases = async (sources, css, template) => {
};
const appearance = element => {
const style = getComputedStyle(element);
- return Object.fromEntries(["position", "backgroundColor", "borderTopLeftRadius", "borderTopRightRadius",
+ return Object.fromEntries(["borderTopLeftRadius", "borderTopRightRadius",
"borderBottomLeftRadius", "borderBottomRightRadius", "marginTop", "boxShadow"]
.map(key => [key, style[key]]));
};
@@ -84,29 +83,58 @@ const browserCases = async (sources, css, template) => {
const leftBar = document.getElementById("dockLeft");
const rightBar = document.getElementById("dockRight");
check.ok(hidden(leftBar) && hidden(rightBar));
+ const {windowMouseMove} = load("mousemove", dependencies);
+ const move = event => windowMouseMove(event);
+ document.addEventListener("mousemove", move);
for (const position of ["Left", "Right"]) {
const dock = docks[position];
const element = position === "Left" ? leftBar : rightBar;
const otherBar = position === "Left" ? rightBar : leftBar;
const entries = Array.from(element.querySelectorAll(".dock__item"));
const order = entries.map(item => item.dataset.entryId);
- open(position);
+ check.equal(dock.layout.element.clientWidth, 0);
+ center.element.dispatchEvent(new MouseEvent("mousemove", {bubbles: true,
+ clientX: position === "Left" ? 1 : window.innerWidth - 1, clientY: 200}));
+ await settle();
+ check.ok(!hidden(element) && hidden(otherBar), "the edge reveals a bar with all panels closed");
+ check.equal(dock.hasActive(), false);
+ check.equal(dock.layout.element.style.opacity, "0", "revealing a bar does not open an empty panel");
+ check.deepEqual(rect(center.element), initialEditor, "bar-only edge hover does not resize the editor");
+ const menu = document.getElementById("commonMenu");
+ menu.style.zIndex = "9999";
+ menu.classList.remove("fn__none");
+ dock.hideDock();
+ check.ok(!hidden(element), "a menu opened from a bar keeps the bar visible without an active panel");
+ menu.classList.add("fn__none");
+ center.element.dispatchEvent(new MouseEvent("mousemove", {bubbles: true,
+ clientX: window.innerWidth / 2, clientY: 200}));
+ await settle();
+ check.ok(hidden(element), "bar-only hover closes after leaving the edge");
+ center.element.dispatchEvent(new MouseEvent("mousemove", {bubbles: true,
+ clientX: position === "Left" ? 1 : window.innerWidth - 1, clientY: 200}));
+ await settle();
+ entries.forEach((entry, index) => entry.addEventListener("click", () =>
+ dock.toggleModel(position + (index === 0 ? "one" : "two"), false, true, false, false)));
+ entries[0].click();
await settle();
+ check.equal(dock.layout.element.style.opacity, "1", "clicking a revealed entry opens its panel");
check.ok(!hidden(element) && hidden(otherBar), "only the expanded side reveals its bar");
- check.ok(rect(center.element).width < initialEditor.width, "a temporary bar uses its normal layout space");
- check.ok(resizes.includes(false), "bar visibility resizes the editor without saving the hidden preference");
+ check.equal(getComputedStyle(element).position, "fixed");
+ check.deepEqual(rect(center.element), initialEditor, "revealing a bar and panel does not resize the editor");
const panelRect = dock.layout.element.getBoundingClientRect();
const barRect = element.getBoundingClientRect();
check.equal(position === "Left" ? panelRect.left : panelRect.right,
position === "Left" ? barRect.right : barRect.left, "panel stays beside the bar");
const temporary = {bar: rect(element), panel: rect(dock.layout.element),
barStyle: appearance(element), panelStyle: appearance(dock.layout.element)};
+ const effectiveBackground = getComputedStyle(element).backgroundColor;
+ check.equal(effectiveBackground, getComputedStyle(document.body).backgroundColor, "bar uses the window background color");
window.siyuan.config.uiLayout.hideDock = false;
bar.syncDockBarVisibility();
dock.showDock(true);
check.deepEqual({bar: rect(element), panel: rect(dock.layout.element),
barStyle: appearance(element), panelStyle: appearance(dock.layout.element)}, temporary,
- "temporary bars preserve the geometry, colors and corners of normally visible bars and panels");
+ "floating bars preserve the normal dock geometry and panel corners");
window.siyuan.config.uiLayout.hideDock = true;
bar.syncDockBarVisibility();
dock.showDock(true);
@@ -115,9 +143,6 @@ const browserCases = async (sources, css, template) => {
await require("electron").ipcRenderer.invoke("dock-bar-capture", position);
}
- const {windowMouseMove} = load("mousemove", dependencies);
- const move = event => windowMouseMove(event);
- document.addEventListener("mousemove", move);
dock.hideDockByHover();
// 覆盖停靠栏最外侧像素,不能因旧的边缘范围少两个像素而收起。
element.dispatchEvent(new MouseEvent("mousemove", {bubbles: true,
@@ -128,24 +153,28 @@ const browserCases = async (sources, css, template) => {
check.equal(dock.layout.element.style.opacity, "1", "moving from panel to bar keeps the panel open");
check.ok(!hidden(element));
- entries[1].addEventListener("click", () => dock.toggleModel(position + "two", false, true, false, false));
entries[1].click();
await settle();
check.ok(entries[1].classList.contains("dock__item--active"));
check.ok(!hidden(dock.layout.element.querySelector(`[data-id="${position}two"]`)));
check.deepEqual(entries.map(item => item.dataset.entryId), order, "plugin entry identifiers and order are preserved");
- check.deepEqual(rect(center.element), expandedEditor, "switching tools preserves the occupied dock space");
+ check.deepEqual(rect(center.element), expandedEditor, "switching tools keeps the editor layout unchanged");
entries[0].classList.add("fn__none");
bar.syncDockBarVisibility();
check.ok(hidden(entries[0]) && !hidden(element), "profile-hidden entries stay hidden during refresh");
entries[0].classList.remove("fn__none");
+ dock.hideDockByHover();
+ dock.showDock(true);
+ await settle();
+ check.ok(hidden(element), "position refreshes do not cancel a pending hover close");
+ dock.showDock();
+
const input = dock.layout.element.querySelector(`[data-id="${position}two"] input`);
input.focus();
dock.hideDock();
check.ok(!hidden(element), "focused input keeps both panel and bar open");
input.blur();
- const menu = document.getElementById("commonMenu");
menu.style.zIndex = "9999";
menu.classList.remove("fn__none");
dock.hideDock();
@@ -158,10 +187,15 @@ const browserCases = async (sources, css, template) => {
check.ok(hidden(element), "leaving the dock and panel restores the hidden state");
check.equal(dock.layout.element.style.opacity, "0");
check.deepEqual(rect(center.element), initialEditor, "closing a temporary bar restores the editor space");
- document.removeEventListener("mousemove", move);
dock.showDock();
dock.togglePanel(false);
check.ok(hidden(element), "explicitly collapsing a panel clears its temporary bar");
+ center.element.dispatchEvent(new MouseEvent("mousemove", {bubbles: true,
+ clientX: position === "Left" ? 1 : window.innerWidth - 1, clientY: 200}));
+ await settle();
+ check.ok(!hidden(element), "edge hover reveals entries when the panel is explicitly collapsed");
+ check.ok(hidden(dock.layout.element), "bar hover preserves the explicit panel collapse");
+ dock.hideDock();
dock.togglePanel(true);
await settle();
check.ok(!hidden(element));
@@ -174,7 +208,13 @@ const browserCases = async (sources, css, template) => {
dock.toggleModel(position + "two", false, true, false, false);
await settle();
check.ok(hidden(element), "closing the final active item hides the temporary bar");
+ center.element.dispatchEvent(new MouseEvent("mousemove", {bubbles: true,
+ clientX: position === "Left" ? 1 : window.innerWidth - 1, clientY: 200}));
+ await settle();
+ check.ok(!hidden(element), "the edge remains usable after closing the last panel");
+ dock.hideDock();
}
+ document.removeEventListener("mousemove", move);
open("Left");
open("Right");
@@ -184,7 +224,8 @@ const browserCases = async (sources, css, template) => {
docks.Left.hideDock();
check.ok(hidden(leftBar) && !hidden(rightBar), "each side closes independently");
check.equal(bottom.element.style.left, "0px");
- check.equal(bottom.element.style.right, rightBar.clientWidth + "px", "bottom panel follows normally occupied side bars");
+ check.equal(bottom.element.style.right, "0px", "temporary bars do not narrow the bottom panel");
+ check.deepEqual(rect(center.element), initialEditor);
docks.Right.hideDock();
check.ok(hidden(leftBar) && hidden(rightBar), "the bottom panel alone reveals no side bars");
check.equal(bottom.element.style.right, "0px", "closing the side bar restores bottom panel width");
@@ -290,16 +331,16 @@ if (process.versions.electron && process.type === "browser") {
}
});
} else {
- test("floating side panels temporarily reveal dock bars using their normal layout and appearance", {
+ test("floating dock bars preserve editor width and remain accessible when every panel is closed", {
skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,
- timeout: 120000,
+ timeout: 180000,
}, async () => {
const env = {...process.env};
delete env.ELECTRON_RUN_AS_NODE;
const profile = mkdtempSync(path.join(os.tmpdir(), "siyuan-dock-bar-"));
try {
const {stdout} = await require("node:util").promisify(require("node:child_process").execFile)(
- require("electron"), [__filename, profile], {env, windowsHide: true, timeout: 115000});
+ require("electron"), [__filename, profile], {env, windowsHide: true, timeout: 175000});
assert.match(stdout, /Floating dock bar cases passed/);
} finally {
assert.equal(path.dirname(path.resolve(profile)), path.resolve(os.tmpdir()));