Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ac.selectItem(0) bug #112

Open
wonderbeyond opened this issue Nov 5, 2014 · 0 comments
Open

ac.selectItem(0) bug #112

wonderbeyond opened this issue Nov 5, 2014 · 0 comments

Comments

@wonderbeyond
Copy link
Contributor

The selectItem method is expected to select the first item, as described in document.

Unfortunately, it's not working as described. Because 0 is evaluated for bool value as one condition in selectItem() to determine whether set selectedIndex attr. so selectedIndex will keep the initial null value if 0 passed, then error occurs:

https://github.com/aralejs/autocomplete/blob/master/src/autocomplete.js#L134

The correct code maybe:

  selectItem: function (index) {
    if (this.items) {
      if ((index || index === 0) && this.items.length > index && index >= -1) {
        this.set('selectedIndex', index);
      }
      this._handleSelection();
    }
  },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant