Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/aria/combobox/combobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ export class Combobox<V> {
afterRenderEffect(() => {
if (
!this._deferredContentAware?.contentVisible() &&
(this._pattern.isFocused() || this.alwaysExpanded())
(this._pattern.focused() || this.alwaysExpanded())
) {
this._deferredContentAware?.contentVisible.set(true);
}
});

afterRenderEffect(() => {
if (!this._hasBeenFocused() && this._pattern.isFocused()) {
if (!this._hasBeenFocused() && this._pattern.focused()) {
this._hasBeenFocused.set(true);
}
});
Expand Down
10 changes: 5 additions & 5 deletions src/aria/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class MenuTrigger<V> {
'role': 'menu',
'class': 'ng-menu',
'[attr.id]': '_pattern.id()',
'[attr.data-visible]': '_pattern.isVisible()',
'[attr.data-visible]': '_pattern.visible()',
'(keydown)': '_pattern.onKeydown($event)',
'(mouseover)': '_pattern.onMouseOver($event)',
'(mouseout)': '_pattern.onMouseOut($event)',
Expand Down Expand Up @@ -171,7 +171,7 @@ export class Menu<V> {
readonly items = () => this._items().map(i => i._pattern);

/** Whether the menu is visible. */
isVisible = computed(() => this._pattern.isVisible());
visible = computed(() => this._pattern.visible());

/** A callback function triggered when a menu item is selected. */
onSelect = output<V>();
Expand Down Expand Up @@ -199,7 +199,7 @@ export class Menu<V> {
this._deferredContentAware?.contentVisible.set(true);
} else {
this._deferredContentAware?.contentVisible.set(
this._pattern.isVisible() || !!this.parent()?.hasBeenFocused(),
this._pattern.visible() || !!this.parent()?.hasBeenFocused(),
);
}
});
Expand All @@ -209,7 +209,7 @@ export class Menu<V> {
// update the display property. The result is focus() being called on an element that is not
// focusable. This simply retries focusing the element after render.
afterRenderEffect(() => {
if (this._pattern.isVisible()) {
if (this._pattern.visible()) {
const activeItem = untracked(() => this._pattern.inputs.activeItem());
this._pattern.listBehavior.goto(activeItem!);
}
Expand Down Expand Up @@ -335,7 +335,7 @@ export class MenuBar<V> {
'class': 'ng-menu-item',
'(focusin)': 'onFocusIn()',
'[attr.tabindex]': '_pattern.tabIndex()',
'[attr.data-active]': '_pattern.isActive()',
'[attr.data-active]': '_pattern.active()',
'[attr.aria-haspopup]': '_pattern.hasPopup()',
'[attr.aria-expanded]': '_pattern.expanded()',
'[attr.aria-disabled]': '_pattern.disabled()',
Expand Down
50 changes: 25 additions & 25 deletions src/aria/private/combobox/combobox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,23 +376,23 @@ describe('Combobox with Listbox Pattern', () => {

it('should select and commit on click', () => {
combobox.onPointerup(clickOption(listbox.inputs.items(), 0));
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.inputs.value()).toEqual(['Apple']);
expect(inputEl.value).toBe('Apple');
});

it('should select and commit to input on Enter', () => {
combobox.onKeydown(down());
combobox.onKeydown(enter());
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.inputs.value()).toEqual(['Apple']);
expect(inputEl.value).toBe('Apple');
});

it('should select on focusout if the input text exactly matches an item', () => {
type('Apple');
combobox.onFocusOut(new FocusEvent('focusout'));
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.inputs.value()).toEqual(['Apple']);
});

Expand All @@ -409,20 +409,20 @@ describe('Combobox with Listbox Pattern', () => {

it('should not select on navigation', () => {
combobox.onKeydown(down());
expect(listbox.getSelectedItems().length).toBe(0);
expect(listbox.selectedItems().length).toBe(0);
expect(listbox.inputs.value()).toEqual([]);
});

it('should not select on input', () => {
type('A');
expect(listbox.getSelectedItems().length).toBe(0);
expect(listbox.selectedItems().length).toBe(0);
expect(listbox.inputs.value()).toEqual([]);
});

it('should not select on focusout if the input text does not match an item', () => {
type('Appl');
combobox.onFocusOut(new FocusEvent('focusout'));
expect(listbox.getSelectedItems().length).toBe(0);
expect(listbox.selectedItems().length).toBe(0);
expect(listbox.inputs.value()).toEqual([]);
expect(inputEl.value).toBe('Appl');
});
Expand All @@ -437,7 +437,7 @@ describe('Combobox with Listbox Pattern', () => {

it('should select and commit on click', () => {
combobox.onPointerup(clickOption(listbox.inputs.items(), 3));
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[3]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[3]);
expect(listbox.inputs.value()).toEqual(['Blackberry']);
expect(inputEl.value).toBe('Blackberry');
});
Expand All @@ -447,20 +447,20 @@ describe('Combobox with Listbox Pattern', () => {
combobox.onKeydown(down());
combobox.onKeydown(down());
combobox.onKeydown(enter());
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[2]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[2]);
expect(listbox.inputs.value()).toEqual(['Banana']);
expect(inputEl.value).toBe('Banana');
});

it('should select the first item on arrow down when collapsed', () => {
combobox.onKeydown(down());
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.inputs.value()).toEqual(['Apple']);
});

it('should select the last item on arrow up when collapsed', () => {
combobox.onKeydown(up());
expect(listbox.getSelectedItems()[0]).toBe(
expect(listbox.selectedItems()[0]).toBe(
listbox.inputs.items()[listbox.inputs.items().length - 1],
);
expect(listbox.inputs.value()).toEqual(['Cranberry']);
Expand All @@ -469,7 +469,7 @@ describe('Combobox with Listbox Pattern', () => {
it('should select on navigation', () => {
combobox.onKeydown(down());
combobox.onKeydown(down());
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[1]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[1]);
expect(listbox.inputs.value()).toEqual(['Apricot']);
});

Expand Down Expand Up @@ -498,7 +498,7 @@ describe('Combobox with Listbox Pattern', () => {

it('should select and commit on click', () => {
combobox.onPointerup(clickOption(listbox.inputs.items(), 3));
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[3]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[3]);
expect(listbox.inputs.value()).toEqual(['Blackberry']);
expect(inputEl.value).toBe('Blackberry');
});
Expand All @@ -508,20 +508,20 @@ describe('Combobox with Listbox Pattern', () => {
combobox.onKeydown(down());
combobox.onKeydown(down());
combobox.onKeydown(enter());
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[2]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[2]);
expect(listbox.inputs.value()).toEqual(['Banana']);
expect(inputEl.value).toBe('Banana');
});

it('should select the first item on arrow down when collapsed', () => {
combobox.onKeydown(down());
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[0]);
expect(listbox.inputs.value()).toEqual(['Apple']);
});

it('should select the last item on arrow up when collapsed', () => {
combobox.onKeydown(up());
expect(listbox.getSelectedItems()[0]).toBe(
expect(listbox.selectedItems()[0]).toBe(
listbox.inputs.items()[listbox.inputs.items().length - 1],
);
expect(listbox.inputs.value()).toEqual(['Cranberry']);
Expand All @@ -530,7 +530,7 @@ describe('Combobox with Listbox Pattern', () => {
it('should select on navigation', () => {
combobox.onKeydown(down());
combobox.onKeydown(down());
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[1]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[1]);
expect(listbox.inputs.value()).toEqual(['Apricot']);
});

Expand Down Expand Up @@ -585,7 +585,7 @@ describe('Combobox with Listbox Pattern', () => {
it('should select and close on selection', () => {
const {combobox, listbox, inputEl} = getPatterns({readonly: true});
combobox.onPointerup(clickOption(listbox.inputs.items(), 2));
expect(listbox.getSelectedItems()[0]).toBe(listbox.inputs.items()[2]);
expect(listbox.selectedItems()[0]).toBe(listbox.inputs.items()[2]);
expect(listbox.inputs.value()).toEqual(['Banana']);
expect(inputEl.value).toBe('Banana');
expect(combobox.expanded()).toBe(false);
Expand Down Expand Up @@ -748,7 +748,7 @@ describe('Combobox with Tree Pattern', () => {
it('should select and commit to input on Enter', () => {
combobox.onKeydown(down());
combobox.onKeydown(enter());
expect(tree.getSelectedItems()[0]).toBe(tree.inputs.allItems()[0]);
expect(tree.selectedItems()[0]).toBe(tree.inputs.allItems()[0]);
expect(tree.inputs.value()).toEqual(['Fruit']);
expect(inputEl.value).toBe('Fruit');
});
Expand All @@ -773,20 +773,20 @@ describe('Combobox with Tree Pattern', () => {

it('should not select on navigation', () => {
combobox.onKeydown(down());
expect(tree.getSelectedItems().length).toBe(0);
expect(tree.selectedItems().length).toBe(0);
expect(tree.inputs.value()).toEqual([]);
});

it('should not select on input', () => {
type('A');
expect(tree.getSelectedItems().length).toBe(0);
expect(tree.selectedItems().length).toBe(0);
expect(tree.inputs.value()).toEqual([]);
});

it('should not select on focusout if the input text does not match an item', () => {
type('Appl');
combobox.onFocusOut(new FocusEvent('focusout'));
expect(tree.getSelectedItems().length).toBe(0);
expect(tree.selectedItems().length).toBe(0);
expect(tree.inputs.value()).toEqual([]);
expect(inputEl.value).toBe('Appl');
});
Expand All @@ -801,7 +801,7 @@ describe('Combobox with Tree Pattern', () => {

it('should select and commit on click', () => {
combobox.onPointerup(clickTreeItem(tree.inputs.allItems(), 2));
expect(tree.getSelectedItems()[0]).toBe(tree.inputs.allItems()[2]);
expect(tree.selectedItems()[0]).toBe(tree.inputs.allItems()[2]);
expect(tree.inputs.value()).toEqual(['Banana']);
expect(inputEl.value).toBe('Banana');
});
Expand All @@ -817,7 +817,7 @@ describe('Combobox with Tree Pattern', () => {

it('should select the first item on arrow down when collapsed', () => {
combobox.onKeydown(down());
expect(tree.getSelectedItems()[0]).toBe(tree.inputs.allItems()[0]);
expect(tree.selectedItems()[0]).toBe(tree.inputs.allItems()[0]);
expect(tree.inputs.value()).toEqual(['Fruit']);
});

Expand Down Expand Up @@ -858,7 +858,7 @@ describe('Combobox with Tree Pattern', () => {

it('should select and commit on click', () => {
combobox.onPointerup(clickTreeItem(tree.inputs.allItems(), 2));
expect(tree.getSelectedItems()[0]).toBe(tree.inputs.allItems()[2]);
expect(tree.selectedItems()[0]).toBe(tree.inputs.allItems()[2]);
expect(tree.inputs.value()).toEqual(['Banana']);
expect(inputEl.value).toBe('Banana');
});
Expand All @@ -874,7 +874,7 @@ describe('Combobox with Tree Pattern', () => {

it('should select the first item on arrow down when collapsed', () => {
combobox.onKeydown(down());
expect(tree.getSelectedItems()[0]).toBe(tree.inputs.allItems()[0]);
expect(tree.selectedItems()[0]).toBe(tree.inputs.allItems()[0]);
expect(tree.inputs.value()).toEqual(['Fruit']);
});

Expand Down
Loading
Loading