Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FSADT1-1079] Contacts page title is initially not visible #708

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions frontend/src/components/grouping/AddressGroupComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ watch([detailsData], () => {
setTimeout(() => (addressControl.value = false), 200);
}
});

onMounted(() => {
if (props.id == 0) safeSetFocusedComponent(`addr_${props.id}`, 800);
else safeSetFocusedComponent(`name_${props.id}`, 200);
});
</script>

<template>
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/components/grouping/ContactGroupComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ const nameTypesToCodeDescr = (
return [];
};

onMounted(() => {
if (props.id === 0) {
safeSetFocusedComponent(`phoneNumber_${props.id}`, 800);
} else {
safeSetFocusedComponent(`firstName_${props.id}`, 800);
}
});

const updateContactType = (value: CodeNameType | undefined) => {
if (value) {
selectedValue.contactType = { value: value.code, text: value.name };
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/pages/bceidform/AddressWizardStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ fetch();

//New address being added
const otherAddresses = computed(() => formData.location.addresses.slice(1));
const addAddress = () => formData.location.addresses.push(emptyAddress());
const addAddress = () => {
const newLength = formData.location.addresses.push(emptyAddress());
const focusIndex = newLength - 1;
safeSetFocusedComponent(`name_${focusIndex}`);
return newLength;
};

//Validation
const validation = reactive<Record<string, boolean>>({
Expand Down Expand Up @@ -110,7 +115,6 @@ const removeAddress = (index: number) => () => {
toastTitle: "",
handler: () => {},
});
safeSetFocusedComponent(`addr_${index - 1}`, 200);
};

const handleRemove = (index: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,6 @@ describe("<AddressGroupComponent />", () => {
.and("include.text", "Error");
});

it("should render the component and set focus on street address input", () => {
cy.get("@addressFixture").then((address) => {
cy.get("@countriesFixture").then((countries) => {
cy.mount(AddressGroupComponent, {
props: {
id: 0,
modelValue: address,
countryList: countries,
validations: [],
},
});
});
});

cy.wait("@getProvinces");

cy.get("#addr_0").should("be.visible").and("have.focus");
});

it("should render the component and show the address name if id is bigger than 0", () => {
cy.get("@addressFixture").then((address) => {
cy.get("@countriesFixture").then((countries) => {
Expand All @@ -173,8 +154,7 @@ describe("<AddressGroupComponent />", () => {

cy.get("#name_1")
.should("be.visible")
.and("have.value", "Mailing address")
.and("have.focus");
.and("have.value", "Mailing address");
});

it("should render the component and reset province when country changes", () => {
Expand Down Expand Up @@ -367,9 +347,6 @@ describe("<AddressGroupComponent />", () => {
});
cy.wait("@getProvinces");

// Prevents issues due to moving focus in the middle of the test.
cy.get("#name_1").should("be.focused");

cy.get(fieldSelector).shadow().find("input").clear(); // emits false
cy.get(fieldSelector).blur(); // (doesn't emit)
cy.get(fieldSelector).shadow().find("input").type(firstContent); // emits true before blurring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ describe("<ContactGroupComponent />", () => {
cy.get("#email_0").contains(contact.email).should("be.visible");

cy.get("#phoneNumber_0").should("be.visible").and("have.value", "");

cy.focused().should('have.id', 'phoneNumber_0');
});
});

Expand Down Expand Up @@ -113,8 +111,6 @@ describe("<ContactGroupComponent />", () => {
cy.get("#email_1").should("be.visible").and("have.value", contact.email);

cy.get("#phoneNumber_1").should("be.visible").and("have.value", "");

cy.focused().should('have.id', 'firstName_1');
});
});

Expand All @@ -139,8 +135,6 @@ describe("<ContactGroupComponent />", () => {
});
});

cy.focused().should('have.id', 'phoneNumber_0');

cy.get("#addressname_0").should("be.visible").and("have.value", "");

cy.get("#addressname_0")
Expand Down Expand Up @@ -176,8 +170,6 @@ describe("<ContactGroupComponent />", () => {
});
});

cy.focused().should('have.id', 'phoneNumber_0');

cy.get("#addressname_0").should("be.visible").and("have.value", "");

cy.get("#addressname_0")
Expand Down Expand Up @@ -220,8 +212,6 @@ describe("<ContactGroupComponent />", () => {
});
});

cy.focused().should('have.id', 'phoneNumber_0');

cy.get("#addressname_0").should("be.visible").and("have.value", "");

cy.get("#addressname_0")
Expand Down Expand Up @@ -276,8 +266,6 @@ describe("<ContactGroupComponent />", () => {
});
});

cy.focused().should('have.id', 'phoneNumber_0');

cy.get("#change-personal-info-link").click();

cy.get("#logout-and-redirect-modal").should("be.visible");
Expand Down Expand Up @@ -335,13 +323,6 @@ describe("<ContactGroupComponent />", () => {
});
});

/*
In case the component is scrolled down, make sure to scroll up so the "First name" input is
visible, since the "safe focusing" would skip focusing it in that case.
*/
cy.scrollTo("top");

cy.focused().should("have.id", "firstName_1");
cy.get(fieldSelector).shadow().find("input").clear(); // emits false
cy.get(fieldSelector).blur(); // (doesn't emit)
cy.get(fieldSelector).shadow().find("input").type(firstContent); // emits true before blurring
Expand Down
Loading