From 8cbe3728f6ba74dd6a5e4f2bb941b801c626766a Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 3 Nov 2026 17:37:37 +0100 Subject: [PATCH] :bug: Fix the mixed and plain labels of the text layout selects The language profile and Japanese layout selects labelled mixed values with "labels.mixed-values", a key that no longer exists, so they showed the raw key. Use "settings.multiple", as the other text options do. The "No language profile" choice had a blank id, which the select shows as "--". Give it the "plain" id and map it back to no language. AI-assisted-by: claude-opus-5-5 --- .../options/menus/text_japanese_layout.cljs | 2 +- .../options/menus/text_language_layout.cljs | 19 ++++++++++++++----- .../frontend_tests/ui/text_options_test.cljs | 13 +++++++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text_japanese_layout.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text_japanese_layout.cljs index 596ba58f39..039a3ef32e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text_japanese_layout.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text_japanese_layout.cljs @@ -44,7 +44,7 @@ (cond-> options (mixed-span-value? value) (conj {:id "mixed" - :label (tr "labels.mixed-values") + :label (tr "settings.multiple") :disabled true :dimmed true}))) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text_language_layout.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text_language_layout.cljs index 48da22222b..cdd46338fa 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text_language_layout.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text_language_layout.cljs @@ -16,9 +16,18 @@ [app.util.text.layout :as tl] [rumext.v2 :as mf])) +;; Id of the "No language profile" choice. The DS select shows "--" for a +;; blank id, so the choice cannot use "". +(def plain-profile "plain") + +(defn selected-profile + "Select id of a paragraph `profile`: the plain choice when unset." + [profile] + (if (= :multiple profile) "multiple" (or profile plain-profile))) + (defn profile-options [language value translate] - (let [options (into [{:id "" :label (translate "workspace.options.text-options.profile-plain")}] + (let [options (into [{:id plain-profile :label (translate "workspace.options.text-options.profile-plain")}] (case language :japanese [{:id "ja" :label (translate "workspace.options.text-options.profile-japanese")}] :chinese [{:id "zh-Hans" :label (translate "workspace.options.text-options.profile-chinese-simplified")} @@ -29,11 +38,11 @@ {:id "zh-Hant-HK" :label (translate "workspace.options.text-options.profile-chinese-hong-kong")}] :korean [{:id "ko" :label (translate "workspace.options.text-options.profile-korean")}])) mixed? (= :multiple value) - id (if mixed? "multiple" (or value ""))] + id (selected-profile value)] (cond-> options (not (some #(= (:id %) id) options)) (conj {:id id - :label (if mixed? (translate "labels.mixed-values") value) + :label (if mixed? (translate "settings.multiple") value) :disabled true :dimmed true})))) @@ -46,7 +55,7 @@ (defn profile-change [value] - {:text-language (when (seq value) value)}) + {:text-language (when (and (seq value) (not= plain-profile value)) value)}) (defn emphasis-position-options [translate] @@ -154,7 +163,7 @@ [{:keys [language values ruby-values text-selection-active reading-selection-active zhuyin-selection-active on-change on-ruby-presentation-change on-blur]}] (let [profile (:text-language values) - selected (if (= :multiple profile) "multiple" (or profile "")) + selected (selected-profile profile) options (mf/with-memo [language profile] (profile-options language profile tr)) matches? (tl/profile-matches? language profile) handle-profile-change (mf/use-fn diff --git a/frontend/test/frontend_tests/ui/text_options_test.cljs b/frontend/test/frontend_tests/ui/text_options_test.cljs index 2071f0b174..175e786fc8 100644 --- a/frontend/test/frontend_tests/ui/text_options_test.cljs +++ b/frontend/test/frontend_tests/ui/text_options_test.cljs @@ -61,7 +61,7 @@ (t/deftest choosing-a-profile-only-changes-the-paragraph-language (t/is (= {:text-language "ko"} (tll/profile-change "ko"))) - (t/is (= {:text-language nil} (tll/profile-change ""))) + (t/is (= {:text-language nil} (tll/profile-change tll/plain-profile))) (t/is (tl/profile-matches? :japanese "ja-JP")) (t/is (tl/profile-matches? :chinese "zh-Hant-TW")) (t/is (tl/profile-matches? :korean "KO-kr")) @@ -72,10 +72,15 @@ (t/deftest profile-choices-keep-mixed-and-other-language-values-visible (let [mixed (last (tll/profile-options :korean :multiple identity)) other (last (tll/profile-options :chinese "ja" identity))] - (t/is (= {:id "multiple" :label "labels.mixed-values" :disabled true :dimmed true} mixed)) + (t/is (= {:id "multiple" :label "settings.multiple" :disabled true :dimmed true} mixed)) (t/is (= {:id "ja" :label "ja" :disabled true :dimmed true} other)) - (t/is (= ["" "zh-Hans" "zh-Hant" "zh-Hans-CN" "zh-Hant-CN" "zh-Hant-TW" "zh-Hant-HK"] - (mapv :id (tll/profile-options :chinese nil identity)))))) + (t/is (= ["plain" "zh-Hans" "zh-Hant" "zh-Hans-CN" "zh-Hant-CN" "zh-Hant-TW" "zh-Hant-HK"] + (mapv :id (tll/profile-options :chinese nil identity)))) + ;; The DS select shows "--" for a blank id, so the plain choice needs one. + (t/is (not-any? (comp str/blank? :id) (tll/profile-options :korean nil identity))) + (t/is (= "plain" (tll/selected-profile nil))) + (t/is (= "multiple" (tll/selected-profile :multiple))) + (t/is (= "ko" (tll/selected-profile "ko"))))) (t/deftest korean-word-wrapping-is-distinct-from-the-saved-experiment (t/is (= ["syllable" "keep-words"]