32 lines
743 B
JavaScript
32 lines
743 B
JavaScript
import Component from '@glimmer/component';
|
|
import { tracked } from "@glimmer/tracking";
|
|
import { action } from "@ember/object";
|
|
|
|
export default class SortableGroupAccessibleComponent extends Component {
|
|
@tracked selectedIndex = 0;
|
|
@tracked groupHasFocus = false;
|
|
|
|
@action
|
|
handleFocus() { this.groupHasFocus = true; }
|
|
|
|
@action
|
|
handleBlur({ target, relatedTarget }) {
|
|
if (!target.contains(relatedTarget)) this.groupHasFocus = false;
|
|
}
|
|
|
|
@action
|
|
handleArrowUp() {
|
|
if (this.selectedIndex > 0) {
|
|
this.selectedIndex -= 1;
|
|
}
|
|
}
|
|
|
|
@action
|
|
handleArrowDown() {
|
|
if (this.selectedIndex < this.args.models.length - 1) {
|
|
this.selectedIndex += 1;
|
|
}
|
|
}
|
|
|
|
preventDefault(evt) { evt.preventDefault(); }
|
|
}
|