🐛 Hide the path edition options when the edited path is gone (#13371)

* 🐛 Hide the path edition options when the edited path is gone

The design panel showed the path edition options whenever a path edit
state existed for the edited shape. The shape can leave the page while
that state stays, for example when another user deletes it or an undo
removes it. The panel then rendered the measures of a missing shape,
with a nil type, and crashed with "No matching clause".

The panel now shows the path edition options only while the edited
path is on the page.

AI-assisted-by: claude-opus-5-5

* ♻️ Name the edited path check apart from its result

The helper and the local that holds its result were both called
path-editing?, so the name meant a function in the namespace and a
boolean inside design-menu*. The helper is now editing-existing-path?.

AI-assisted-by: claude-opus-5-5
This commit is contained in:
Eva Marco 2026-11-27 13:12:38 +01:00 committed by GitHub
parent 3fd984e12e
commit 324ac9afe7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 1 deletions

View File

@ -115,6 +115,14 @@
(recur (pop queue) visited)))
(sequence (keep (d/getf objects)) visited))))
(defn- editing-existing-path?
"Whether the path `edition` is being edited. The shape can leave the
page while its edit state stays, e.g. deleted by another user or undone;
then there is no path to edit."
[edit-path edition objects]
(and (path.state/editing? edit-path edition)
(contains? objects edition)))
(mf/defc design-menu*
{::mf/private true}
[{:keys [selected objects page-id file-id shapes]}]
@ -129,7 +137,7 @@
(path.state/current-edit-state edit-path edition)
path-editing?
(path.state/editing? edit-path edition)
(editing-existing-path? edit-path edition objects)
path-content
(dm/get-in drawing [:object :content])

View File

@ -175,6 +175,7 @@
[frontend-tests.ui.mcp-authorize-test]
[frontend-tests.ui.measurements-test]
[frontend-tests.ui.measures-menu-props-test]
[frontend-tests.ui.options-path-editing-test]
[frontend-tests.ui.organization-team-switch-test]
[frontend-tests.ui.routes-test]
[frontend-tests.ui.settings-password-schema-test]
@ -393,6 +394,7 @@
'frontend-tests.ui.layout-container-multiple-test
'frontend-tests.ui.measurements-test
'frontend-tests.ui.measures-menu-props-test
'frontend-tests.ui.options-path-editing-test
'frontend-tests.ui.organization-team-switch-test
'frontend-tests.ui.mcp-authorize-test
'frontend-tests.ui.routes-test

View File

@ -0,0 +1,33 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns frontend-tests.ui.options-path-editing-test
"The design panel shows the path edition options only while the edited
path is on the page. Its edit state can outlive the shape (deleted by
another user, undone), and the panel crashed on the missing shape."
(:require
[app.common.uuid :as uuid]
[app.main.ui.workspace.sidebar.options :as options]
[cljs.test :as t :include-macros true]))
(def ^:private editing-existing-path?
@#'options/editing-existing-path?)
(t/deftest path-editing-while-the-path-is-on-the-page
(let [id (uuid/next)
edit-path {id {:edit-mode :move}}
objects {id {:id id :type :path}}]
(t/is (true? (editing-existing-path? edit-path id objects)))))
(t/deftest no-path-editing-when-the-edited-path-left-the-page
(let [id (uuid/next)
edit-path {id {:edit-mode :move}}]
(t/is (false? (editing-existing-path? edit-path id {})))))
(t/deftest no-path-editing-without-edit-state
(let [id (uuid/next)
objects {id {:id id :type :path}}]
(t/is (false? (editing-existing-path? {} id objects)))))