From 750e1b1c5b0bead433ed7363b928056fe446b404 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Wed, 10 Jun 2026 13:59:14 -0400 Subject: [PATCH] Fix preferred powder search dropdown not appearing Inline display:none!important on the results div blocked all CSS rules from showing it, including the :not(:empty) trick. Switched to explicit JS show/hide so the dropdown is reliably visible after typing 2+ chars. Co-Authored-By: Claude Sonnet 4.6 --- src/PowderCoating.Web/Views/Customers/Details.cshtml | 8 ++------ src/PowderCoating.Web/wwwroot/js/customer-details.js | 10 +++++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/PowderCoating.Web/Views/Customers/Details.cshtml b/src/PowderCoating.Web/Views/Customers/Details.cshtml index d5e5a82..54e3948 100644 --- a/src/PowderCoating.Web/Views/Customers/Details.cshtml +++ b/src/PowderCoating.Web/Views/Customers/Details.cshtml @@ -823,9 +823,8 @@ oninput="searchInventoryItems(this.value)" autocomplete="off" /> - +
-
diff --git a/src/PowderCoating.Web/wwwroot/js/customer-details.js b/src/PowderCoating.Web/wwwroot/js/customer-details.js index 23028f8..3975635 100644 --- a/src/PowderCoating.Web/wwwroot/js/customer-details.js +++ b/src/PowderCoating.Web/wwwroot/js/customer-details.js @@ -99,7 +99,10 @@ let _powderSearchTimer = null; function searchInventoryItems(term) { clearTimeout(_powderSearchTimer); const dropdown = document.getElementById('powderSearchResults'); - if (!term || term.length < 2) { if (dropdown) dropdown.innerHTML = ''; return; } + if (!term || term.length < 2) { + if (dropdown) { dropdown.innerHTML = ''; dropdown.style.display = 'none'; } + return; + } _powderSearchTimer = setTimeout(async () => { try { @@ -109,7 +112,8 @@ function searchInventoryItems(term) { dropdown.innerHTML = data.length === 0 ? '' : data.map(i => ``).join(''); + onclick="selectPowder(${i.id}, ${JSON.stringify(i.name + (i.colorName ? ' — ' + i.colorName : ''))})">${i.name}${i.colorName ? ' ' + i.colorName + '' : ''} ${i.sku ?? ''}`).join(''); + dropdown.style.display = 'block'; } catch { /* silent */ } }, 300); } @@ -118,7 +122,7 @@ function selectPowder(itemId, label) { document.getElementById('selectedPowderId').value = itemId; document.getElementById('powderSearchInput').value = label; const dropdown = document.getElementById('powderSearchResults'); - if (dropdown) dropdown.innerHTML = ''; + if (dropdown) { dropdown.innerHTML = ''; dropdown.style.display = 'none'; } } async function addPreferredPowder(customerId) {