From b7582a5a75eab356a191c64ff5ddd9aa4eba6802 Mon Sep 17 00:00:00 2001 From: Will Wu Date: Mon, 4 May 2026 15:54:27 +0800 Subject: [PATCH] fix: prevent blocks from being outdented past zoom root in focused view When viewing a page in zoom/focus mode, pressing Shift+Tab could outdent blocks past the zoom root boundary, causing them to disappear from the focused view. This adds a guard in both single-block (indent-outdent) and multi-block (on-tab) code paths to check for the zoom boundary. Fixes #12582 --- src/main/frontend/handler/editor.cljs | 30 ++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 2823dd5b4e..1e1d41f4fc 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -1642,8 +1642,17 @@ (defn on-tab "`direction` = :left | :right." [direction] - (let [blocks (get-selected-ordered-blocks)] - (block-handler/indent-outdent-blocks! blocks (= direction :right) nil))) + (let [blocks (get-selected-ordered-blocks) + indent? (= direction :right) + page (state/get-current-page) + zoom-root (when (and (not indent?) page (util/uuid-string? page)) + (db/entity [:block/uuid (parse-uuid page)])) + blocks (if zoom-root + (remove (fn [b] + (= (:db/id (:block/parent b)) (:db/id zoom-root))) + blocks) + blocks)] + (block-handler/indent-outdent-blocks! blocks indent? nil))) (defn- get-link [format link label] (let [link (or link "") @@ -2486,11 +2495,18 @@ (when block (let [node block-container prev-container-id (get-node-container-id node) - container-id (get-new-container-id (if indent? :indent :outdent) {})] - (p/do! - (block-handler/indent-outdent-blocks! [block] indent? save-current-block!) - (when (and (not= prev-container-id container-id) container-id) - (state/set-editing-block-id! [container-id (:block/uuid block)]))))))) + container-id (get-new-container-id (if indent? :indent :outdent) {}) + outdent-past-zoom-root? (when-not indent? + (let [page (state/get-current-page)] + (and page + (util/uuid-string? page) + (let [zoom-root (db/entity [:block/uuid (parse-uuid page)])] + (= (:db/id (:block/parent block)) (:db/id zoom-root))))))] + (when-not outdent-past-zoom-root? + (p/do! + (block-handler/indent-outdent-blocks! [block] indent? save-current-block!) + (when (and (not= prev-container-id container-id) container-id) + (state/set-editing-block-id! [container-id (:block/uuid block)])))))))) (defn keydown-tab-handler [direction]