Skip to content

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

:bug: Keep database row navigation aligned on the left https://github.com/siyuan-note/siyuan/issues/20407

Daniel22b75c2569a5
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scss
index 755b4f3511..6f1f595854 100644
--- a/app/src/assets/scss/protyle/_protyle.scss
+++ b/app/src/assets/scss/protyle/_protyle.scss
@@ -315,6 +315,10 @@
}
}
+ &__navigation .block__icon:first-child {
+ margin-left: 0;
+ }
+
&__space {
min-width: 8px;
transition: var(--b3-transition);
diff --git a/app/src/protyle/render/av/databaseRowNavigation.ts b/app/src/protyle/render/av/databaseRowNavigation.ts
index 3dcee42cd7..d4a5ca6625 100644
--- a/app/src/protyle/render/av/databaseRowNavigation.ts
+++ b/app/src/protyle/render/av/databaseRowNavigation.ts
@@ -118,12 +118,8 @@ export const mountDatabaseRowNavigation = (container: Element, data: IDatabaseRo
toolbar.setAttribute("data-database-row-navigation", data.itemID);
toolbar.innerHTML = ["previous", "next"].map((name, index) =>
`<button type="button" data-row-navigation="${name}" disabled class="block__icon block__icon--show block__icon--tap ariaLabel" data-position="8south" aria-label="${escapeAttr(window.siyuan.languages[name])}"><svg><use xlink:href="#${index ? "iconDown" : "iconUp"}"></use></svg></button>`)
- .join(inline ? "" : '<span class="fn__space"></span>');
- if (inline) {
- breadcrumb.insertBefore(toolbar, breadcrumb.querySelector(':scope > [data-type="readonly"]'));
- } else {
- container.prepend(toolbar);
- }
+ .join(inline ? "" : '<span class="fn__space"></span>') + (inline ? '<span class="fn__space"></span>' : "");
+ (inline ? breadcrumb : container).prepend(toolbar);
const buttons = Array.from(toolbar.querySelectorAll("button"));
let busy = false;
const update = async () => {
diff --git a/app/tests/databaseRowNavigation.test.js b/app/tests/databaseRowNavigation.test.js
index 51d557fa17..264887b7ba 100644
--- a/app/tests/databaseRowNavigation.test.js
+++ b/app/tests/databaseRowNavigation.test.js
@@ -71,7 +71,7 @@ const runCases = async (sources, css, touch) => {
const menu = breadcrumb.querySelector('[data-type="mobile-menu"]');
const control = breadcrumb.querySelector('[data-type="more"]').getBoundingClientRect();
check.ok(control.right <= window.innerWidth, JSON.stringify({control, width: window.innerWidth}));
- check.equal(toolbar.nextElementSibling, breadcrumb.querySelector('[data-type="readonly"]'));
+ check.equal(toolbar, breadcrumb.firstElementChild);
check.equal(menu.getBoundingClientRect().height, 24);
for (const button of buttons) {
check.equal(button.disabled, false);
@@ -79,11 +79,11 @@ const runCases = async (sources, css, touch) => {
check.equal(rect.height, control.height);
check.equal(rect.width, control.width);
check.equal(rect.top, control.top);
- check.ok(rect.left >= menu.getBoundingClientRect().right);
- check.ok(rect.right <= breadcrumb.querySelector('[data-type="readonly"]').getBoundingClientRect().left);
+ check.ok(rect.right <= menu.getBoundingClientRect().left);
check.ok(rect.right <= window.innerWidth);
check.ok(button.contains(document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2)), "navigation button must not be covered");
}
+ const inlinePositions = buttons.map(button => button.getBoundingClientRect().left - breadcrumb.getBoundingClientRect().left);
const spacer = parseFloat(getComputedStyle(editor.querySelector(".protyle-content"), "::before").height);
check.equal(spacer, merged ? 42 : 90);
check.ok(breadcrumb.getBoundingClientRect().bottom <= spacer);
@@ -149,6 +149,9 @@ const runCases = async (sources, css, touch) => {
check.equal(standalone[0].height, control.height);
check.equal(standalone[0].left - row.getBoundingClientRect().left, 8);
check.equal(standalone[1].left - standalone[0].right, 8);
+ inlinePositions.forEach((left, index) => {
+ check.equal(left, standalone[index].left - row.getBoundingClientRect().left);
+ });
context = {environment: "desktop", focus: "global", activeElement: document.body, activeTab: {element: tab}};
check.equal(commands.getDatabaseRowNavigationButton(context, "nextDatabaseRow"), row.querySelector('[data-row-navigation="next"]'));
tab.classList.add("fn__none");