From 7ec2b6df289774eb0cf5f58ca8775bdc94ec9019 Mon Sep 17 00:00:00 2001 From: Mouriya Date: Thu, 19 Sep 2024 21:03:00 +0900 Subject: [PATCH] =?UTF-8?q?=E9=96=93=E9=81=95=E3=81=A3=E3=81=9F=E3=82=A4?= =?UTF-8?q?=E3=83=86=E3=83=AC=E3=83=BC=E3=82=BF=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?.=20=20=E4=B8=8D=E6=AD=A3=E3=81=AA=E3=82=A4=E3=83=B3=E3=83=87?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=82=B9=E6=AF=94=E8=BC=83=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/actions/cascading-dropdown-selectors.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugin/kintone-addins/src/actions/cascading-dropdown-selectors.ts b/plugin/kintone-addins/src/actions/cascading-dropdown-selectors.ts index 78199b6..9e01dae 100644 --- a/plugin/kintone-addins/src/actions/cascading-dropdown-selectors.ts +++ b/plugin/kintone-addins/src/actions/cascading-dropdown-selectors.ts @@ -318,14 +318,15 @@ namespace DropdownContainer { ".control-label-text-gaia" ); } - - headerCells.forEach((th, index) => { - const label = th.textContent?.trim(); - const field = fieldList.find((f) => f.dropDown.label === label); - if (field) { + headerCells = Array.from(headerCells); + for (const field of fieldList) { + const index = headerCells + .map((th) => th.textContent?.trim()) + .findIndex((label) => label === field.dropDown.label); + if (index) { columnMap.set(index, field); } - }); + } // columnMapの作成後は変更されないため、その配列バージョンを再構築しません columMapArray = Array.from(columnMap.entries()); columMapValueArray = Array.from(columnMap.values()); @@ -415,10 +416,10 @@ namespace DropdownContainer { const selectorChangeHandle = (fieldCode: string, event: Event): void => { const select = event.target as HTMLSelectElement; state[fieldCode] = select.value; // 値を状態に同期 - + const currentLevel = getLevel(fieldCode); // すべての下位メニューをリセット columMapArray - .filter(([index, _]) => index >= getLevel(fieldCode) + 1) + .filter((_, arrayIndex) => arrayIndex > currentLevel) .forEach(([_, field]) => { const fieldCode = field.dropDown.code; updateOptions(fieldCode);