Added enter event logic in sticker reprint #443

Merged
jothi merged 1 commits from ranjith-dev into master 2026-03-07 03:24:25 +00:00
2 changed files with 16 additions and 4 deletions

View File

@@ -281,7 +281,7 @@ class StickerReprint extends Page implements HasForms
} }
}) })
->extraAttributes(fn ($get) => [ ->extraAttributes(fn ($get) => [
'id' => 'scan_locator_no', 'id' => 'production_order',
'class' => $get('productionError') ? 'border-red-500' : '', 'class' => $get('productionError') ? 'border-red-500' : '',
]) ])
->hint(fn ($get) => $get('productionError') ? $get('productionError') : null) ->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
@@ -421,6 +421,7 @@ class StickerReprint extends Page implements HasForms
// 'operator_id'=> $operatorName, // 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr, 'recent_qr' => $this->recQr,
]); ]);
$this->dispatch('focus-qr-input');
$this->triggerChartUpdate(); $this->triggerChartUpdate();
} }
} }

View File

@@ -34,22 +34,33 @@
</div> </div>
@push('scripts') @push('scripts')
<script> <script>
window.addEventListener('focus-qr-input', () => {
const input = document.getElementById('qr-scan-input');
if (input) {
input.focus();
input.select();
}
});
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const scanInput = document.getElementById('qr-scan-input'); const scanInput = document.getElementById('qr-scan-input');
if (!scanInput) return; if (!scanInput) return;
scanInput.addEventListener('keydown', function (event) { scanInput.addEventListener('keydown', function (event) {
if (event.key === 'Enter') { if (event.key == 'Enter') {
event.preventDefault(); event.preventDefault();
const value = scanInput.value.trim(); const value = scanInput.value.trim();
if (value !== '') { //if (value !== '') {
Livewire.dispatch('handleQrScan', { value: value }); Livewire.dispatch('handleQrScan', { value: value });
scanInput.value = ''; scanInput.value = '';
} //}
} }
}); });
window.addEventListener('open-pdf', event => { window.addEventListener('open-pdf', event => {