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 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 13:59:14 -04:00
parent 94a89ee175
commit 750e1b1c5b
2 changed files with 9 additions and 9 deletions
@@ -823,9 +823,8 @@
oninput="searchInventoryItems(this.value)"
autocomplete="off" />
<input type="hidden" id="selectedPowderId" />
<div id="powderSearchResults" class="dropdown-menu w-100 show p-0"
style="display:none!important;position:absolute;z-index:1000;"
onfocusout=""></div>
<div id="powderSearchResults" class="dropdown-menu w-100 p-0"
style="display:none;position:absolute;z-index:1000;max-height:200px;overflow-y:auto;"></div>
</div>
<div class="mb-2">
<input type="text" id="powderNotes" class="form-control form-control-sm"
@@ -839,9 +838,6 @@
</div>
</div>
</div>
<style>
#powderSearchResults:not(:empty) { display:block!important; max-height:200px; overflow-y:auto; }
</style>
<!-- Quick Actions -->
<div class="card border-0 shadow-sm">
@@ -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
? '<div class="dropdown-item text-muted small">No results</div>'
: data.map(i => `<button type="button" class="dropdown-item small"
onclick="selectPowder(${i.id}, ${JSON.stringify(i.name + (i.colorName ? ' — ' + i.colorName : ''))})">${i.name}${i.colorName ? ' <span class=\'text-muted\'>' + i.colorName + '</span>' : ''} <span class="badge bg-light text-muted border">${i.sku}</span></button>`).join('');
onclick="selectPowder(${i.id}, ${JSON.stringify(i.name + (i.colorName ? ' — ' + i.colorName : ''))})">${i.name}${i.colorName ? ' <span class=\'text-muted\'>' + i.colorName + '</span>' : ''} <span class="badge bg-light text-muted border">${i.sku ?? ''}</span></button>`).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) {