Skip to content

onkeydown result does not bubble back up to ember-power-select #79

@mikeburg

Description

@mikeburg

The onkeydown action handler does not bubble up the keydown action result back up to the ember-power-select. So if the handler wanted to stop the event, EPS never sees the request to stop processing.

The code for onKeyDown method in component/ember-power-select-typeahead.js is:

    onKeyDown(select, e) {
      let action = this.get('onkeydown');

      // if user passes `onkeydown` action
      if (!action || action(select, e) !== false) {
        // if escape, then clear out selection
        if (e.keyCode === 27) {
          select.actions.choose(null);
        }
      }
    }

It really should be:

  onKeyDown(select, e) {
      let action = this.get('onkeydown');

      // if user passes `onkeydown` action
      const result = action ? action(select, e) : undefined;

      if (!action || result !== false) {
        // if escape, then clear out selection
        if (e.keyCode === 27) {
          select.actions.choose(null);
        }
      }
      return result;
    }

This allow the onkeydown action result to bubble back up to ember-power-select itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions