@tagplus/components 4.10.3 → 4.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "email": "bruno@tagplus.com.br"
9
9
  }
10
10
  ],
11
- "version": "4.10.3",
11
+ "version": "4.10.5",
12
12
  "main": "./dist/tp.common.js",
13
13
  "directories": {
14
14
  "lib": "src/lib"
@@ -379,6 +379,25 @@ export default {
379
379
  }
380
380
  },
381
381
 
382
+ watch: {
383
+ suggestions () {
384
+ // Quando os resultados da busca chegam e há um select pendente (Enter pressionado antes da busca completar)
385
+ if (this._pendingSelectAfterSearch) {
386
+ this._pendingSelectAfterSearch = false
387
+ this.$nextTick(() => {
388
+ // Seleciona o primeiro item visível (não-created) da lista
389
+ for (let i = 0; i < this.options.length; ++i) {
390
+ const option = this.options[i]
391
+ if (!option.disabled && !option.groupDisabled && option.visible && !option.created) {
392
+ this.handleOptionSelect(option)
393
+ return
394
+ }
395
+ }
396
+ })
397
+ }
398
+ }
399
+ },
400
+
382
401
  created () {
383
402
  this.debouncedOnInputChange = debounce(this.debounce, e => {
384
403
  // Correção para mobile ativar a busca enquanto digita
@@ -562,6 +581,42 @@ export default {
562
581
  return newOption
563
582
  },
564
583
 
584
+ /**
585
+ * Sobrescreve selectOption do el-select para evitar que o mouseenter de um item da lista
586
+ * sobreponha a seleção correta ao pressionar Enter (ex: leitor de código de barras).
587
+ * Quando o texto digitado ainda não foi buscado (debounce pendente), dispara a busca
588
+ * imediatamente e seleciona o primeiro resultado quando a lista atualizar.
589
+ */
590
+ selectOption () {
591
+ if (!this.visible) {
592
+ this.toggleMenu()
593
+ return
594
+ }
595
+
596
+ // Se o usuário digitou algo novo que ainda não foi buscado (debounce pendente)
597
+ if (this.filterable && this.selectedLabel && this.selectedLabel !== this.query) {
598
+ // Dispara a busca imediatamente sem esperar o debounce
599
+ this._pendingSelectAfterSearch = true
600
+ this.onInputChange()
601
+ return
602
+ }
603
+
604
+ // Recalcula o hoverIndex para o primeiro item visível, ignorando hover do mouse
605
+ if (this.query) {
606
+ for (let i = 0; i < this.options.length; ++i) {
607
+ const option = this.options[i]
608
+ if (!option.disabled && !option.groupDisabled && option.visible && !option.created) {
609
+ this.hoverIndex = i
610
+ break
611
+ }
612
+ }
613
+ }
614
+
615
+ if (this.options[this.hoverIndex]) {
616
+ this.handleOptionSelect(this.options[this.hoverIndex])
617
+ }
618
+ },
619
+
565
620
  checkDefaultFirstOption () {
566
621
  this.$nextTick(() => {
567
622
  this.hoverIndex = -1