Skip to content

Commit 65bff87

Browse files
committed
fix focus bug when setting a topic to na
1 parent 66b0a75 commit 65bff87

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

confiture-web-app/src/components/audit/AuditGenerationPageCriteria.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,15 @@ const noResults = computed(() => {
5151
}
5252
});
5353
54-
const notApplicableSwitchRefs = ref<InstanceType<typeof NotApplicableSwitch>[]>(
55-
[]
56-
);
54+
const notApplicableSwitchRefs =
55+
ref<Record<number, InstanceType<typeof NotApplicableSwitch> | null>>({});
56+
57+
// put ref in notApplicableSwitchRefs record based on given topic number
58+
const refFn =
59+
(topicNumber: number) =>
60+
(el: any) =>
61+
notApplicableSwitchRefs.value[topicNumber] =
62+
el as InstanceType<typeof NotApplicableSwitch>;
5763
5864
// Focus topic NA switch when setting last topic criterion as NA
5965
watch(
@@ -65,8 +71,8 @@ watch(
6571
(newValue) => {
6672
if (newValue) {
6773
notApplicableSwitchRefs.value[
68-
resultsStore.lastUpdatedTopic - 1
69-
].focusInput();
74+
resultsStore.lastUpdatedTopic
75+
]?.focusInput();
7076
}
7177
}
7278
);
@@ -107,7 +113,7 @@ watch(
107113
{{ topic.number }}. {{ topic.topic }}
108114
</h3>
109115
<NotApplicableSwitch
110-
ref="notApplicableSwitchRefs"
116+
:ref="refFn(topic.number)"
111117
:page-id="page.id"
112118
:topic-number="topic.number"
113119
:topic-title="topic.topic"

0 commit comments

Comments
 (0)