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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user