From 74fd2471bc388357d449c179445e54586c09a64e Mon Sep 17 00:00:00 2001 From: NotAbdelrahmanelsayed Date: Wed, 15 Apr 2026 19:15:24 +0200 Subject: [PATCH] feat: select first search result on Enter key press When the user presses Enter in the item search box and search results are visible, the first result is added to the cart immediately instead of falling back to an exact barcode lookup (which showed "Item Not Found" for partial text). Barcode lookup is preserved as the fallback when no search results are present. Co-Authored-By: Claude Sonnet 4.6 --- POS/src/composables/useSearchInput.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/POS/src/composables/useSearchInput.js b/POS/src/composables/useSearchInput.js index fb32dd54..b87dae59 100644 --- a/POS/src/composables/useSearchInput.js +++ b/POS/src/composables/useSearchInput.js @@ -75,18 +75,24 @@ export function useSearchInput({ itemStore, onItemFound, showWarning, isAnyDialo // Snapshot the barcode NOW from the DOM input, before anything overwrites it const barcode = searchInputRef.value?.value?.trim() || itemStore.searchTerm?.trim() - if (barcode) { - // Clear input immediately so next scan starts clean - itemStore.clearSearch() - if (searchInputRef.value) searchInputRef.value.value = "" - - // Queue the search with the captured barcode - processBarcodeScan(barcode, autoAddEnabled.value) + if (!barcode) return + + // If search results are visible, add the first one directly + const firstResult = itemStore.filteredItems?.[0] + if (firstResult && itemStore.searchTerm) { + onItemFound(firstResult, autoAddEnabled.value) + clearSearchAndResetInput() + focusSearchInput() + return } + + // No search results → fall back to barcode lookup + itemStore.clearSearch() + if (searchInputRef.value) searchInputRef.value.value = "" + processBarcodeScan(barcode, autoAddEnabled.value) return } // All other keys: no special handling needed. - // Dead scanner-speed-detection code removed. } /**