Skip to content

Commit

Permalink
Single component can be opened and closed with the spacebar (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
cibernox committed Apr 27, 2016
1 parent 059023d commit 7900f5e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,7 @@
# Master

- [BUGFIX] The component can and closed with the spacebar while the trigger is focused.

# 0.10.1
- [ENHANCEMENT] Allow trigger the `onfocus` action from within the trigger component.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -66,7 +66,7 @@
"dependencies": {
"ember-cli-babel": "^5.1.6",
"ember-cli-htmlbars": "^1.0.3",
"ember-basic-dropdown": "^0.11.0",
"ember-basic-dropdown": "^0.11.3",
"ember-hash-helper-polyfill": "^0.1.0",
"ember-truth-helpers": "^1.2.0"
},
Expand Down
26 changes: 23 additions & 3 deletions tests/integration/components/power-select/keyboard-control-test.js
Expand Up @@ -172,12 +172,12 @@ test('The component is focusable using the TAB key as any other kind of input',
assert.equal(this.$('.ember-power-select-trigger').attr('tabindex'), "0", 'The trigger is reachable with TAB');
});

test('If the component is focused, pressing ENTER opens it', function(assert) {
assert.expect(2);
test('If the component is focused, pressing ENTER toggles it', function(assert) {
assert.expect(3);

this.numbers = numbers;
this.render(hbs`
{{#power-select options=numbers onchange=(action (mut foo)) as |option|}}
{{#power-select options=numbers onchange=(action (mut foo)) searchEnabled=false as |option|}}
{{option}}
{{/power-select}}
`);
Expand All @@ -186,6 +186,26 @@ test('If the component is focused, pressing ENTER opens it', function(assert) {
assert.equal($('.ember-power-select-dropdown').length, 0, 'The select is closed');
triggerKeydown($('.ember-power-select-trigger')[0], 13);
assert.equal($('.ember-power-select-dropdown').length, 1, 'The select is opened');
triggerKeydown($('.ember-power-select-trigger')[0], 13);
assert.equal($('.ember-power-select-dropdown').length, 0, 'The select is closed again');
});

test('If the single component is focused, pressing SPACE toggles it', function(assert) {
assert.expect(3);

this.numbers = numbers;
this.render(hbs`
{{#power-select options=numbers onchange=(action (mut foo)) searchEnabled=false as |option|}}
{{option}}
{{/power-select}}
`);

Ember.run(() => $('.ember-power-select-trigger').focus());
assert.equal($('.ember-power-select-dropdown').length, 0, 'The select is closed');
triggerKeydown($('.ember-power-select-trigger')[0], 32);
assert.equal($('.ember-power-select-dropdown').length, 1, 'The select is opened');
triggerKeydown($('.ember-power-select-trigger')[0], 32);
assert.equal($('.ember-power-select-dropdown').length, 0, 'The select is closed again');
});

test('If the single component is focused, pressing KEYDOWN opens it', function(assert) {
Expand Down

0 comments on commit 7900f5e

Please sign in to comment.