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);