Skip to content

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

:bug: Preserve mobile top bars when entering body input https://github.com/siyuan-note/siyuan/issues/20018

Daniel30b49d39b690
diff --git a/app/src/mobile/util/mobileBars.test.ts b/app/src/mobile/util/mobileBars.test.ts
index 091191bf3e..40bc93d7b6 100644
--- a/app/src/mobile/util/mobileBars.test.ts
+++ b/app/src/mobile/util/mobileBars.test.ts
@@ -126,9 +126,19 @@ describe("mobile bars", () => {
assert.equal(topbarElement.attributes.has("inert"), false);
assert.equal(topbarElement.attributes.get("aria-hidden"), "false");
assert.equal(classes.has("mobile-chrome--hidden"), false);
+ assert.equal(breadcrumbElement.attributes.has("inert"), false);
+ assert.equal(breadcrumbElement.attributes.get("aria-hidden"), "false");
+ };
+ const scrollTo = (top: number) => {
+ scrollElement.scrollTop = top;
+ scrollElement.onScroll();
+ frame(0);
};
if (keyboardAlreadyOpen) {
changeKeyboard(true);
+ assertTitleVisible();
+ finishScroll();
+ scrollTo(48);
assert.equal(topbarElement.attributes.has("inert"), true);
}
mockDocument.activeElement = {id: "toolbarName"};
@@ -148,7 +158,14 @@ describe("mobile bars", () => {
assertTitleVisible();
assert.equal(bottomBarElement.attributes.has("inert"), false);
changeKeyboard(true);
+ assertTitleVisible();
+ assert.equal(bottomBarElement.attributes.has("inert"), true);
+ finishScroll();
+ scrollTo(148);
assert.equal(topbarElement.attributes.has("inert"), true);
+ assert.equal(breadcrumbElement.attributes.has("inert"), true);
+ scrollTo(100);
+ assertTitleVisible();
});
}
diff --git a/app/src/mobile/util/mobileBarsState.test.ts b/app/src/mobile/util/mobileBarsState.test.ts
index 7d5df2daa1..c2a7951110 100644
--- a/app/src/mobile/util/mobileBarsState.test.ts
+++ b/app/src/mobile/util/mobileBarsState.test.ts
@@ -78,11 +78,11 @@ describe("mobile bars state", () => {
assert.equal(getVisibility(state).topbarVisible, true);
});
- it("hides the top bars on entering input and reveals them when scrolling back", () => {
+ it("preserves visible top bars on entering input and still follows scrolling", () => {
let state = createMobileBarsState(100);
state = update(state, {type: "set-editing", active: true});
assert.deepEqual(getVisibility(state), {
- topbarVisible: false,
+ topbarVisible: true,
bottomBarVisible: false,
editingBarVisible: true,
scrollPaused: false,
@@ -101,6 +101,17 @@ describe("mobile bars state", () => {
assert.equal(getVisibility(state).bottomBarVisible, true);
});
+ it("preserves a partial reading offset when the keyboard opens and closes", () => {
+ let state = createMobileBarsState(100);
+ state = update(state, {type: "scroll", scrollTop: 112});
+ state = update(state, {type: "set-editing", active: true, scrollTop: 140});
+ assert.equal(state.readingBarsOffset, 12);
+ assert.equal(state.scrollTop, 140);
+ state = update(state, {type: "set-editing", active: false, scrollTop: 160});
+ assert.equal(state.readingBarsOffset, 12);
+ assert.equal(state.scrollTop, 160);
+ });
+
it("preserves hidden bars across keyboard changes and ignores cursor scrolling", () => {
let state = createMobileBarsState(100);
state = update(state, {type: "set-reading-bars", visible: false});
diff --git a/app/src/mobile/util/mobileBarsState.ts b/app/src/mobile/util/mobileBarsState.ts
index 6ae206fc5d..3bb7c75246 100644
--- a/app/src/mobile/util/mobileBarsState.ts
+++ b/app/src/mobile/util/mobileBarsState.ts
@@ -111,7 +111,6 @@ export const reduceMobileBarsState = (
return {
...resetScrollTracking(state, action.scrollTop),
editing: action.active,
- readingBarsOffset: action.active && !state.editing ? scrollOptions.maxOffset : state.readingBarsOffset,
};
}