🐛 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
This commit is contained in:
alonso.torres 2026-11-03 17:37:37 +01:00
parent 1817871f51
commit 8cbe3728f6
3 changed files with 24 additions and 10 deletions

View File

@ -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})))

View File

@ -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

View File

@ -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"]