cibernox / cibernox/ember-power-select-typeahead

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

Open
#79 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
37
Forks
57
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start in component/ember-power-select-typeahead.js and inspect the onKeyDown method shown in the issue. Confirm that the user-provided onkeydown result is returned while preserving the existing Escape-key behavior. Done means ember-power-select can receive a false result and stop processing the event.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.