diff --git a/src/PowderCoating.Web/wwwroot/js/item-wizard.js b/src/PowderCoating.Web/wwwroot/js/item-wizard.js index 6bdb869..75ae77f 100644 --- a/src/PowderCoating.Web/wwwroot/js/item-wizard.js +++ b/src/PowderCoating.Web/wwwroot/js/item-wizard.js @@ -394,10 +394,21 @@ function renderProductFields() { } function filterCatalog() { - const q = document.getElementById('catalogSearch').value.toLowerCase(); - document.querySelectorAll('#catalogListbox .catalog-list-item').forEach(el => { - el.style.display = (q && !el.textContent.toLowerCase().includes(q)) ? 'none' : ''; + const q = document.getElementById('catalogSearch').value.toLowerCase(); + const words = q.split(/\s+/).filter(Boolean); + const listbox = document.getElementById('catalogListbox'); + if (!listbox) return; + listbox.querySelectorAll('.catalog-list-item').forEach(el => { + const text = el.textContent.toLowerCase(); + const hide = words.length > 0 && !words.every(w => text.includes(w)); + el.style.display = hide ? 'none' : ''; }); + // Reset scroll so filtered-in items are always visible at the top. + listbox.scrollTop = 0; + // Force a layout recalculation — required on iOS Safari so elements that + // transition from display:none back to visible register as interactive. + // eslint-disable-next-line no-unused-expressions + listbox.offsetHeight; } function pickCatalogItem(el) {