間違ったイテレータを修正. 不正なインデックス比較を修正

This commit is contained in:
Mouriya
2024-09-19 21:03:00 +09:00
parent 4eb66684da
commit 7ec2b6df28

View File

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