corejavascript / corejavascript/typeahead.js

autocomplete() should trigger autocomplete event even when text already matches

Open
#132 3 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
JavaScript
Stars
968
Forks
231
PR merge metrics
No merged PRs in 30d

Description

Currently, [`autocomplete()`](https://github.com/corejavascript/typeahead.js/blob/78971040cc6c02f12100ed48b1d2f5719c04c5c6/src/typeahead/typeahead.js#L371) doesn't trigger the `autocomplete` event if the input text matches the given `$selectable`. Why should it, if autocompletion won't change the text?

Because there may be other data attached to the typeahead choice which is extracted by downstream logic listening for the event.

Instead of
```JavaScript
isValid = data && query !== data.val;
if (isValid && !this.eventBus.before('autocomplete', data.obj, data.dataset)) {
```
it should be just
```JavaScript
if (data && !this.eventBus.before('autocomplete', data.obj, data.dataset)) {
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.