diff --git a/frontend/src/app/main/ui/ds/product/input_with_meta.cljs b/frontend/src/app/main/ui/ds/product/input_with_meta.cljs index 396d724fcb..b787a381da 100644 --- a/frontend/src/app/main/ui/ds/product/input_with_meta.cljs +++ b/frontend/src/app/main/ui/ds/product/input_with_meta.cljs @@ -51,6 +51,7 @@ (fn [event] (dom/stop-propagation event) (reset! editing* false) + (mf/set-ref-val! last-node* nil) (when on-blur (on-blur event)))) @@ -77,7 +78,9 @@ :on-blur on-stop-edit :on-key-down handle-key-down})] - ;; Cleanup: Simulate a blur event + ;; Cleanup: simulate a blur only for an edit that never blurred. + ;; on-stop-edit clears last-node*, so a finished edit is not replayed + ;; when the row unmounts. (mf/with-effect [on-blur last-node*] (fn [] (let [input (mf/ref-val last-node*) diff --git a/frontend/src/app/plugins/library.cljs b/frontend/src/app/plugins/library.cljs index 8fccd73b83..d72607fb9e 100644 --- a/frontend/src/app/plugins/library.cljs +++ b/frontend/src/app/plugins/library.cljs @@ -715,7 +715,7 @@ (->> (get-variant-components file-id id) (mapcat :variant-properties) (keep :name) - (set) + (distinct) (apply array)))} :currentValues @@ -726,7 +726,7 @@ (->> variant-properties (d/seek #(= (:name %) property))))) (keep :value) - (set) + (distinct) (apply array))) :variantComponents diff --git a/frontend/test/frontend_tests/plugins/library_test.cljs b/frontend/test/frontend_tests/plugins/library_test.cljs index 721d6bd0ef..bbe1379a3c 100644 --- a/frontend/test/frontend_tests/plugins/library_test.cljs +++ b/frontend/test/frontend_tests/plugins/library_test.cljs @@ -366,6 +366,17 @@ (t/is (= [plugin-id :removeProperty "Plugin doesn't have 'library:write' permission"] (first @errors))))))) +(t/deftest variant-properties-keep-order-past-eight + (let [names (mapv #(str "Property " %) (range 1 12)) + values (mapv #(str "Value " %) (range 1 12)) + components (mapv (fn [value] + {:variant-properties (mapv #(hash-map :name % :value value) names)}) + values)] + (with-redefs [library/get-variant-components (constantly components)] + (let [proxy (library/variant-proxy plugin-id (uuid/next) (uuid/next))] + (t/is (= names (vec (.-properties proxy)))) + (t/is (= values (vec (.currentValues proxy "Property 9")))))))) + (t/deftest variant-rename-property-checks-permission (let [plugin-id "test-plugin" file-id (uuid/next) diff --git a/plugins/CHANGELOG.md b/plugins/CHANGELOG.md index 22948e3705..d2ea6b03df 100644 --- a/plugins/CHANGELOG.md +++ b/plugins/CHANGELOG.md @@ -24,6 +24,7 @@ - **plugins-runtime**: `TokenFontFamilies.resolvedValue` and the `fontFamilies` member of `TokenTypographyValue` now keep a family whose name has several words (`Hanken Grotesk`) as one entry, instead of splitting it into an array of its words, and keep names with words the resolver would otherwise read as colors or numbers (`Red Hat Display`, `Press Start 2P`) unchanged. - **plugins-runtime:** A SES `repairIntrinsics` failure at startup (for example, when a browser extension wraps the native `Temporal` global) no longer leaves the whole app blank. Plugins are skipped for that session, the error is logged, and a telemetry event reports the unavailable runtime; the editor, login and sign-up pages load as usual. Plugins work as before in every other environment. When startup fails, SES has already replaced `Function.prototype.toString` in the host realm before throwing, but no intrinsics are hardened and no sandbox is created. Closes #12924. - **plugins-runtime:** `Variants.removeProperty()` no longer leaves two variants with the same values. When several variants clash, the top one in the layers panel keeps its values and each lower one gets a numbered value (`Big (1)`, or `(1)` when all its remaining values are empty). Closes #12959. +- **plugins-runtime:** `Variants.properties` and `Variants.currentValues()` keep the order of the variant properties and values when there are more than eight. They used to come back shuffled, so `removeProperty()` and `renameProperty()` could hit the wrong property when called with an index read from `properties`. Closes #13247. ## 1.6.0 (2026-11-10) diff --git a/plugins/apps/plugin-api-test-suite/src/tests/variants.test.ts b/plugins/apps/plugin-api-test-suite/src/tests/variants.test.ts index ace7b44d32..f8b1fd4e29 100644 --- a/plugins/apps/plugin-api-test-suite/src/tests/variants.test.ts +++ b/plugins/apps/plugin-api-test-suite/src/tests/variants.test.ts @@ -295,6 +295,28 @@ describe('Variants', () => { } }); + test('variant properties keep their order past eight', async (ctx) => { + const vc = await variantComponent(ctx); + const v = vc.variants!; + while (v.properties.length < 10) { + const before = v.properties.length; + v.addProperty(); + await waitFor(() => v.properties.length > before); + } + expect(v.properties).toHaveLength(10); + + v.renameProperty(4, 'Middle'); + await waitFor(() => v.properties[4] === 'Middle'); + const renamed = [...v.properties]; + expect(renamed[4]).toBe('Middle'); + expect(new Set(renamed).size).toBe(10); + + const removed = renamed[8]; + v.removeProperty(8); + await waitFor(() => v.properties.length === 9); + expect(v.properties).toEqual(renamed.filter((name) => name !== removed)); + }); + test('addVariant and setVariantProperty mutate the variant', async (ctx) => { const vc = await variantComponent(ctx); const v = vc.variants;