From 2a18cd5f634acbb32fa7b434acbbfb4db882595c Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 5 Mar 2026 15:02:33 +0530 Subject: [PATCH] Added focus to production order and qr input in production quantity page --- app/Filament/Pages/ProductionQuantityPage.php | 7 +++---- .../filament/pages/production-quantity.blade.php | 13 +++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Filament/Pages/ProductionQuantityPage.php b/app/Filament/Pages/ProductionQuantityPage.php index 99def3c..997027a 100644 --- a/app/Filament/Pages/ProductionQuantityPage.php +++ b/app/Filament/Pages/ProductionQuantityPage.php @@ -352,7 +352,8 @@ class ProductionQuantityPage extends Page implements HasForms } }) ->extraAttributes(fn ($get) => [ - 'id' => 'scan_locator_no', + 'id' => 'production_order', + 'wire:keydown.enter' => '$dispatch("focus-qr-input")', 'class' => $get('productionError') ? 'border-red-500' : '', ]) ->hint(fn ($get) => $get('productionError') ? $get('productionError') : null) @@ -508,12 +509,11 @@ class ProductionQuantityPage extends Page implements HasForms // 'operator_id'=> $operatorName, 'recent_qr' => $this->recQr, ]); + $this->dispatch('focus-production-order'); $this->triggerChartUpdate(); } } - // Method to process the value when Enter is pressed - #[On('handleQrScan')] public function handleQrScan($value) { @@ -571,7 +571,6 @@ class ProductionQuantityPage extends Page implements HasForms ->body('Scan the valid QR code.
(Ex: Item_Code|Serial_Number )') ->danger() ->send(); - return; } else { if (! $this->pId) { diff --git a/resources/views/filament/pages/production-quantity.blade.php b/resources/views/filament/pages/production-quantity.blade.php index 0ddf762..99a5a25 100644 --- a/resources/views/filament/pages/production-quantity.blade.php +++ b/resources/views/filament/pages/production-quantity.blade.php @@ -87,6 +87,15 @@ } }); + window.addEventListener('focus-qr-input', () => { + const input = document.getElementById('qr-scan-input'); + + if (input) { + input.focus(); + input.select(); + } + }); + document.addEventListener('DOMContentLoaded', function () { const scanInput = document.getElementById('qr-scan-input'); if (!scanInput) return; @@ -97,10 +106,10 @@ const value = scanInput.value.trim(); - if (value !== '') { + // if (value != '') { Livewire.dispatch('handleQrScan', { value: value }); scanInput.value = ''; - } + // } } });