Commit eace506
fix: fire onSearchComplete before onSelect when auto-selecting (#870)
When a search returns a single suggestion whose value exactly matches
the current query and `triggerSelectOnValidInput` is true (the default),
`suggest()` calls `select(0)` which fires `onSelect`. Previously, the
three response paths (function lookup, cached/local, ajax) all fired
`onSearchComplete` after `suggest()`, so consumers received the events
in the wrong order — onSelect before onSearchComplete — making any
cleanup logic in onSearchComplete clobber state set during onSelect.
Move `onSearchComplete` ahead of `suggest()` (and `processResponse()`
on the ajax path, which contains `suggest()`) so the events fire in
the natural order: search-complete, then any resulting select.
Closes #852.
Co-authored-by: Tomas Kirda <tomas.kirda@bisoncommerce.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 85796a9 commit eace506
5 files changed
Lines changed: 33 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
403 | | - | |
404 | 403 | | |
| 404 | + | |
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
420 | 419 | | |
| 420 | + | |
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | | - | |
434 | 433 | | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
412 | 411 | | |
| 412 | + | |
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
428 | 427 | | |
| 428 | + | |
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
442 | 441 | | |
| 442 | + | |
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
| 420 | + | |
420 | 421 | | |
| 422 | + | |
421 | 423 | | |
422 | 424 | | |
423 | 425 | | |
| |||
434 | 436 | | |
435 | 437 | | |
436 | 438 | | |
437 | | - | |
438 | 439 | | |
| 440 | + | |
439 | 441 | | |
440 | 442 | | |
441 | 443 | | |
| |||
451 | 453 | | |
452 | 454 | | |
453 | 455 | | |
454 | | - | |
455 | 456 | | |
| 457 | + | |
456 | 458 | | |
457 | 459 | | |
458 | 460 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
711 | 732 | | |
712 | 733 | | |
713 | 734 | | |
| |||
0 commit comments