Skip to content

Commit 8b65f6c

Browse files
committed
feat: listen for modal status opened/closed and add required attribute
1 parent 1883de8 commit 8b65f6c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

apps/website/src/components/GetYourPlanForm.astro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ const enableModalForm = import.meta.env.PUBLIC_ENABLE_MODAL_FORM === "true";
113113
"#get-your-plan-form-loader",
114114
);
115115

116+
submitBtn?.addEventListener("click", () => {
117+
const startDateInput = document.getElementById("form-start-date");
118+
if (startDateInput) {
119+
startDateInput.setAttribute("required", "");
120+
}
121+
});
122+
116123
const notificationElem = form?.querySelector("#form-notification");
117124

118125
/* Modal part of form elements */
@@ -144,10 +151,20 @@ const enableModalForm = import.meta.env.PUBLIC_ENABLE_MODAL_FORM === "true";
144151
};
145152

146153
const handleCloseModal = () => {
154+
const startDateInput = document.getElementById("form-start-date");
155+
if (startDateInput) {
156+
startDateInput.removeAttribute("required");
157+
}
147158
getPlanModal?.close();
148159
};
149160

150161
if (getPlanModal) {
162+
getPlanModal.addEventListener("close", () => {
163+
const startDateInput = document.getElementById("form-start-date");
164+
if (startDateInput) {
165+
startDateInput.removeAttribute("required");
166+
}
167+
});
151168
getPlanModal.addEventListener("click", handleModalSoftDismiss);
152169
submitBtn?.addEventListener("click", handleOpenModal);
153170
}

0 commit comments

Comments
 (0)