From c1a17e491b25e40ed9962a15916084f126a9cf69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Mon, 18 May 2026 18:24:37 -0300 Subject: [PATCH 1/2] fix: adjust return order on normalizeSelectAllField function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/utils/methods.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/methods.js b/src/utils/methods.js index b52505028..cb93e33d2 100644 --- a/src/utils/methods.js +++ b/src/utils/methods.js @@ -601,19 +601,19 @@ export const normalizeSelectAllField = ( listName, allSelected ) => { - if (!items?.length) + const isAllSelected = allSelected ?? items?.includes("all"); + if (isAllSelected) { return { - [flagName]: false, + [flagName]: true, [listName]: [] }; + } - const isAllSelected = allSelected ?? items.includes("all"); - if (isAllSelected) { + if (!items?.length) return { - [flagName]: true, + [flagName]: false, [listName]: [] }; - } return { [flagName]: false, [listName]: items.map((a) => a.id ?? a) From 06cf653d72435d0c65918fadb915aa74937278a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Castillo?= Date: Tue, 19 May 2026 10:53:51 -0300 Subject: [PATCH 2/2] fix: add test cases for allSelected prop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Castillo --- src/utils/__tests__/methods.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/utils/__tests__/methods.test.js b/src/utils/__tests__/methods.test.js index 32fee9298..ac5275c43 100644 --- a/src/utils/__tests__/methods.test.js +++ b/src/utils/__tests__/methods.test.js @@ -86,6 +86,24 @@ describe("getMediaInputValue", () => { }); }); + it.each([[], null, undefined])( + "should return apply_to_all true when allSelected is true and items is %s", + (items) => { + expect( + normalizeSelectAllField(items, "apply_to_all", "items", true) + ).toEqual({ apply_to_all: true, items: [] }); + } + ); + + it.each([[], null, undefined])( + "should return apply_to_all false when allSelected is false and items is %s", + (items) => { + expect( + normalizeSelectAllField(items, "apply_to_all", "items", false) + ).toEqual({ apply_to_all: false, items: [] }); + } + ); + it("should return array of ids when items are objects with id", () => { expect( normalizeSelectAllField([{ id: 1 }, { id: 2 }], "apply_to_all", "items")