From 56c4b5381e13a765c9e03b5df6d43d344a9cfca7 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Thu, 6 Mar 2025 15:18:18 -0500 Subject: [PATCH] tweak td sizing to be dynamic --- src/registrar/assets/src/js/getgov/form-nameservers.js | 7 ++++++- src/registrar/templates/domain_nameservers.html | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/registrar/assets/src/js/getgov/form-nameservers.js b/src/registrar/assets/src/js/getgov/form-nameservers.js index 49ad9d691..cf9884724 100644 --- a/src/registrar/assets/src/js/getgov/form-nameservers.js +++ b/src/registrar/assets/src/js/getgov/form-nameservers.js @@ -142,17 +142,22 @@ export class NameserverForm { let ipInput = document.getElementById(`id_form-${formIndex}-ip`); if (serverInput && ipInput) { let ipParent = ipInput.parentElement; // Get the parent element of ipInput + let ipTd = ipParent.parentElement; // add an event listener on the server input that adjusts visibility // and value of the ip input (and its parent) serverInput.addEventListener("input", () => { let serverValue = serverInput.value.trim(); - if (ipParent) { + if (ipParent && ipTd) { if (serverValue.endsWith('.' + this.domain)) { showElement(ipParent); // Show IP field if the condition matches + ipTd.classList.add('width-40p'); } else { hideElement(ipParent); // Hide IP field otherwise + ipTd.classList.remove('width-40p'); ipInput.value = ""; // Set the IP value to blank } + } else { + console.warn("Expected DOM element but did not find it"); } }); } diff --git a/src/registrar/templates/domain_nameservers.html b/src/registrar/templates/domain_nameservers.html index 20986eb22..f201388c4 100644 --- a/src/registrar/templates/domain_nameservers.html +++ b/src/registrar/templates/domain_nameservers.html @@ -5,8 +5,8 @@ {% block domain_content %} - {# this is right after the messages block in the parent template #} - {% if formset.total_form_count >= formset.max_num %} + {# this is right after the messages block in the parent template. We use > not >= to account for the blank form. #} + {% if formset.total_form_count > formset.max_num %}