Skip to content

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

:bug: Prevent database toolbar overflow on narrow mobile screens https://github.com/siyuan-note/siyuan/issues/19626

Danielfb30f9089747
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss
index f4acff441a..716a021cc0 100644
--- a/app/src/assets/scss/business/_av.scss
+++ b/app/src/assets/scss/business/_av.scss
@@ -162,6 +162,7 @@
}
&__views--mobile {
+ flex-wrap: wrap;
gap: 4px;
min-width: 0;
@@ -176,7 +177,7 @@
> .av__mobile-view {
flex: 0 1 auto;
min-width: 64px;
- max-width: 10em;
+ max-width: min(10em, 100%);
overflow: hidden;
gap: 4px;
diff --git a/app/src/protyle/render/av/backlinkSticky.test.ts b/app/src/protyle/render/av/backlinkSticky.test.ts
index 9ac75775bc..b11686ea54 100644
--- a/app/src/protyle/render/av/backlinkSticky.test.ts
+++ b/app/src/protyle/render/av/backlinkSticky.test.ts
@@ -8,7 +8,7 @@ const compiled = transpileModule(readFileSync("src/protyle/render/av/row.ts", "u
compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2021},
}).outputText;
-test("sticky views follow visible breadcrumbs and return to the viewport top when hidden", () => {
+test("sticky views follow breadcrumbs and keep wrapped height in sync when resized", () => {
const exports: {stickyRow?: (block: unknown, scroll: unknown, status: string) => void} = {};
runInNewContext(compiled, {
exports,
@@ -16,19 +16,21 @@ test("sticky views follow visible breadcrumbs and return to the viewport top whe
window: {innerHeight: 800},
});
let paneBottom = 800;
+ let viewsWidth = 400;
const views = {
classList: {contains: (name: string) => name === "av__views--fixed"},
- offsetHeight: 40,
+ get offsetHeight() { return parseFloat(this.style.width) < 300 ? 80 : 40; },
style: {top: "", left: "", width: "", clipPath: ""},
closest: (selector: string) => ({
getBoundingClientRect: () => ({
top: 24, bottom: selector === ".layout-tab-container" ? paneBottom : 800, left: 0, right: 500,
}),
}),
- getBoundingClientRect: () => ({top: parseFloat(views.style.top), bottom: parseFloat(views.style.top) + 40, left: 20, right: 420}),
+ getBoundingClientRect: () => ({top: parseFloat(views.style.top), bottom: parseFloat(views.style.top) + views.offsetHeight, left: 20, right: 20 + viewsWidth}),
nextElementSibling: {
classList: {contains: (name: string) => name === "av__views-placeholder"},
- getBoundingClientRect: () => ({top: -100, left: 20, width: 400}),
+ style: {height: "40px"},
+ getBoundingClientRect: () => ({top: -100, left: 20, width: viewsWidth}),
},
};
const block = {
@@ -80,6 +82,16 @@ test("sticky views follow visible breadcrumbs and return to the viewport top whe
previousTop = top;
}
}
+ hidden = false;
+ breadcrumbBottom = 72;
+ paneBottom = 120;
+ for (const width of [280, 400, 280]) {
+ viewsWidth = width;
+ exports.stickyRow(block, scroll, "top");
+ assert.equal(views.style.width, width + "px");
+ assert.equal(views.nextElementSibling.style.height, width < 300 ? "80px" : "40px");
+ assert.equal(views.style.clipPath, width < 300 ? "inset(0px 0px 32px 0px)" : "inset(0px 0px 0px 0px)");
+ }
});
test("backlink scrolling clears fixed rows and their spacers without calculating window positions", () => {
diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.ts
index 189dff9bd3..97b207f7be 100644
--- a/app/src/protyle/render/av/row.ts
+++ b/app/src/protyle/render/av/row.ts
@@ -634,8 +634,18 @@ export const stickyRow = (blockElement: HTMLElement, scrollElement: HTMLElement,
? viewsElement.nextElementSibling as HTMLElement
: viewsElement;
const viewsRect = placeholderElement.getBoundingClientRect();
- const blockRect = blockElement.getBoundingClientRect();
+ // 吸顶栏按当前可用宽度换行,并同步占位高度,保持表头位置与文档布局一致。
+ if (placeholderElement !== viewsElement) {
+ const width = Math.round(viewsRect.width) + "px";
+ if (viewsElement.style.width !== width) {
+ viewsElement.style.width = width;
+ }
+ }
const height = viewsElement.offsetHeight;
+ if (placeholderElement !== viewsElement && placeholderElement.style.height !== height + "px") {
+ placeholderElement.style.height = height + "px";
+ }
+ const blockRect = blockElement.getBoundingClientRect();
const shouldFix = height > 0 && viewsRect.top < stickyTop && blockRect.bottom > stickyTop;
const top = blockRect.bottom < stickyTop + height ? Math.round(blockRect.bottom - height) : stickyTop;
viewsTask = {