Skip to content

Commit

Permalink
add dropdown primitive ctd
Browse files Browse the repository at this point in the history
  • Loading branch information
amk221 committed Dec 11, 2024
1 parent f3deaf5 commit a52e954
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
10 changes: 0 additions & 10 deletions addon/components/select-box/index.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,6 @@ export default class SelectBox extends Component {
this._ensureFocus();
}

@action
handleFocusOut() {
if (this.dropdown) {
return;
}

this._forgetActiveOption();
}

@action
handleKeyDownTrigger(event) {
this._handleKeyDown(event);
Expand Down Expand Up @@ -671,7 +662,6 @@ export default class SelectBox extends Component {
data-disabled="{{this.isDisabled}}"
{{on "mouseleave" this.handleMouseLeave}}
{{on "mousedown" this.handleMouseDown}}
{{on "focusout" this.handleFocusOut}}
{{lifecycle
onInsert=this.handleInsertElement
onDestroy=this.handleDestroyElement
Expand Down
1 change: 0 additions & 1 deletion tests/dummy/app/styles/example.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
@mixin dropdown-content {
display: flex;
flex-direction: column;
overflow: auto;
}

@mixin options {
Expand Down
4 changes: 4 additions & 0 deletions tests/dummy/app/styles/example3.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
height: 240px;
}

.select-box__options {
@include example.options;
}

.select-box__option {
@include example.option;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/dummy/app/styles/example4.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
height: 282px;
}

.select-box__options {
@include example.options;
}

.select-box__option {
@include example.option;
}
Expand Down
12 changes: 4 additions & 8 deletions tests/integration/components/select-box/index/focus-test.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,9 @@ module('select-box (focus)', function (hooks) {
);
});

test('focus out listbox forgets active option', async function (assert) {
test('focus out does not forget active option', async function (assert) {
assert.expect(2);

// We only show the active option when the select box has focus,
// because it is receptive to user input and therefore can
// be selected. When not focused, there is no need for it.
// This is the equivalent of when a select box with a dropdown
// (a combobox) is closed.

await render(<template>
<SelectBox as |sb|>
<sb.Options>
Expand All @@ -620,7 +614,9 @@ module('select-box (focus)', function (hooks) {

await blur('.select-box__options');

assert.dom('.select-box__option[aria-current="true"]').doesNotExist();
assert
.dom('.select-box__option:nth-child(2)')
.hasAttribute('aria-current', 'true');
});

test('keyboard-focusable-scrollers fix', async function (assert) {
Expand Down

0 comments on commit a52e954

Please sign in to comment.