From 5100e5ec5b9d5586aa842ea5d178c6ffda4f18a5 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Wed, 8 Feb 2023 09:19:20 -0500 Subject: [PATCH] CSR-1012 - Uncommented code that is for selecting the first item when clicking outside of box --- .../address-questions/address-questions.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue index a3e49369c..9ed26f29d 100644 --- a/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue +++ b/src/layouts/address-lookup/customer-questions/address-questions/address-questions.vue @@ -277,6 +277,24 @@ export default { } }); + addressField1.addEventListener("change", () => { + // If a match has been previously attempted then do nothing + if (self.matchFound !== null) { + return; + } + + // Get the address that the user clicked on (if any) + const clickedAddress = document.querySelector( + ".pac-container .pac-item:hover" + ); + + // If the Street Address field changed without clicking (i.e. by pressing Tab, or clicking outside the field) + if (clickedAddress === null) { + // Fill-in the address using first item in the list. + fillInAddressUsingFirstItem(); + } + }); + function fillInAddressUsingFirstItem() { // Fill-in the address using first item in the list. const item = document.querySelector(".pac-container .pac-item");