Skip to content

Commit

Permalink
feat: focus the first field, which depends
Browse files Browse the repository at this point in the history
  • Loading branch information
fterra-encora committed Dec 7, 2023
1 parent dddcdd9 commit a8ee97b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion frontend/src/components/grouping/ContactGroupComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ const nameTypesToCodeDescr = (
};
onMounted(() => {
setFocusedComponent(`address_${props.id}`, 800);
if (props.id === 0) {
setFocusedComponent(`phoneNumber_${props.id}`, 800);
} else {
setFocusedComponent(`firstName_${props.id}`, 800);
}
});
const updateContactType = (value: CodeNameType | undefined) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/FormBCeIDPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ const scrollToNewContact = () => {
// Skip auto-focus so to do it only when scroll is done.
const index = contactWizardRef.value.addContact(false) - 1;
setScrollPoint(`additional-contact-${index}`, undefined, () => {
setFocusedComponent(`addressname_${index}`);
setFocusedComponent(`firstName_${index}`);
});
}
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/bceidform/ContactWizardStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const addContact = (autoFocus = true) => {
);
if (autoFocus) {
const focusIndex = newLength - 1;
setFocusedComponent(`addressname_${focusIndex}`);
setFocusedComponent(`firstName_${focusIndex}`);
}
return newLength;
};
Expand Down Expand Up @@ -129,7 +129,7 @@ const handleRemove = (index: number) => {
});
};
onMounted(() => setFocusedComponent("addressname_0", 800));
onMounted(() => setFocusedComponent("phoneNumber_0", 800));
defineExpose({
addContact,
Expand Down

0 comments on commit a8ee97b

Please sign in to comment.