Skip to content
Merged
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/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class AccordionPanel {
'[attr.aria-controls]': '_pattern.controls()',
'[attr.aria-disabled]': '_pattern.disabled()',
'[attr.disabled]': 'hardDisabled() ? true : null',
'[attr.tabindex]': '_pattern.tabindex()',
'[attr.tabindex]': '_pattern.tabIndex()',
'(keydown)': '_pattern.onKeydown($event)',
'(pointerdown)': '_pattern.onPointerdown($event)',
'(focusin)': '_pattern.onFocus($event)',
Expand All @@ -122,7 +122,7 @@ export class AccordionTrigger {
*
* TODO(ok7sai): Consider move this to UI patterns.
*/
readonly hardDisabled = computed(() => this._pattern.disabled() && this._pattern.tabindex() < 0);
readonly hardDisabled = computed(() => this._pattern.disabled() && this._pattern.tabIndex() < 0);

/** The accordion panel pattern controlled by this trigger. This is set by AccordionGroup. */
readonly accordionPanel: WritableSignal<AccordionPanelPattern | undefined> = signal(undefined);
Expand Down
2 changes: 1 addition & 1 deletion src/aria/combobox/combobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Combobox<V> {
'role': 'combobox',
'[value]': 'value()',
'[attr.aria-expanded]': 'combobox._pattern.expanded()',
'[attr.aria-activedescendant]': 'combobox._pattern.activedescendant()',
'[attr.aria-activedescendant]': 'combobox._pattern.activeDescendant()',
'[attr.aria-controls]': 'combobox._pattern.popupId()',
'[attr.aria-haspopup]': 'combobox._pattern.hasPopup()',
'[attr.aria-autocomplete]': 'combobox._pattern.autocomplete()',
Expand Down
6 changes: 3 additions & 3 deletions src/aria/listbox/listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ import {ComboboxPopup} from '../combobox';
'role': 'listbox',
'class': 'ng-listbox',
'[attr.id]': 'id()',
'[attr.tabindex]': '_pattern.tabindex()',
'[attr.tabindex]': '_pattern.tabIndex()',
'[attr.aria-readonly]': '_pattern.readonly()',
'[attr.aria-disabled]': '_pattern.disabled()',
'[attr.aria-orientation]': '_pattern.orientation()',
'[attr.aria-multiselectable]': '_pattern.multi()',
'[attr.aria-activedescendant]': '_pattern.activedescendant()',
'[attr.aria-activedescendant]': '_pattern.activeDescendant()',
'(keydown)': '_pattern.onKeydown($event)',
'(pointerdown)': '_pattern.onPointerdown($event)',
'(focusin)': 'onFocus()',
Expand Down Expand Up @@ -198,7 +198,7 @@ export class Listbox<V> {
'class': 'ng-option',
'[attr.data-active]': '_pattern.active()',
'[attr.id]': '_pattern.id()',
'[attr.tabindex]': '_pattern.tabindex()',
'[attr.tabindex]': '_pattern.tabIndex()',
'[attr.aria-selected]': '_pattern.selected()',
'[attr.aria-disabled]': '_pattern.disabled()',
},
Expand Down
4 changes: 2 additions & 2 deletions src/aria/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {Directionality} from '@angular/cdk/bidi';
exportAs: 'ngMenuTrigger',
host: {
'class': 'ng-menu-trigger',
'[attr.tabindex]': '_pattern.tabindex()',
'[attr.tabindex]': '_pattern.tabIndex()',
'[attr.aria-haspopup]': '_pattern.hasPopup()',
'[attr.aria-expanded]': '_pattern.expanded()',
'[attr.aria-controls]': '_pattern.menu()?.id()',
Expand Down Expand Up @@ -340,7 +340,7 @@ export class MenuBar<V> {
'role': 'menuitem',
'class': 'ng-menu-item',
'(focusin)': 'onFocusIn()',
'[attr.tabindex]': '_pattern.tabindex()',
'[attr.tabindex]': '_pattern.tabIndex()',
'[attr.data-active]': '_pattern.isActive()',
'[attr.aria-haspopup]': '_pattern.hasPopup()',
'[attr.aria-expanded]': '_pattern.expanded()',
Expand Down
4 changes: 2 additions & 2 deletions src/aria/private/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export class AccordionTriggerPattern {
/** Id of the accordion panel controlled by the trigger. */
controls = computed(() => this.inputs.accordionPanel()?.id());

/** The tabindex of the trigger. */
tabindex = computed(() => (this.inputs.accordionGroup().focusManager.isFocusable(this) ? 0 : -1));
/** The tab index of the trigger. */
tabIndex = computed(() => (this.inputs.accordionGroup().focusManager.isFocusable(this) ? 0 : -1));

/** Whether the trigger is disabled. Disabling an accordion group disables all the triggers. */
disabled = computed(() => this.inputs.disabled() || this.inputs.accordionGroup().disabled());
Expand Down
24 changes: 12 additions & 12 deletions src/aria/private/behaviors/grid-focus/grid-focus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,17 @@ describe('GridFocus', () => {
describe('getGridTabindex', () => {
it('should return 0 if grid is disabled', () => {
const {gridFocus} = setupGridFocus({disabled: signal(true)});
expect(gridFocus.getGridTabindex()).toBe(0);
expect(gridFocus.getGridTabIndex()).toBe(0);
});

it('should return -1 if focusMode is "roving" and grid is not disabled', () => {
const {gridFocus} = setupGridFocus({focusMode: signal('roving')});
expect(gridFocus.getGridTabindex()).toBe(-1);
expect(gridFocus.getGridTabIndex()).toBe(-1);
});

it('should return 0 if focusMode is "activedescendant" and grid is not disabled', () => {
const {gridFocus} = setupGridFocus({focusMode: signal('activedescendant')});
expect(gridFocus.getGridTabindex()).toBe(0);
expect(gridFocus.getGridTabIndex()).toBe(0);
});
});

Expand All @@ -252,9 +252,9 @@ describe('GridFocus', () => {
numCols: 3,
disabled: signal(true),
});
expect(gridFocus.getCellTabindex(cells[0][0])).toBe(-1);
expect(gridFocus.getCellTabindex(cells[0][1])).toBe(-1);
expect(gridFocus.getCellTabindex(cells[0][2])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][0])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][1])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][2])).toBe(-1);
});

it('should return -1 if focusMode is "activedescendant"', () => {
Expand All @@ -263,9 +263,9 @@ describe('GridFocus', () => {
numCols: 3,
focusMode: signal('activedescendant'),
});
expect(gridFocus.getCellTabindex(cells[0][0])).toBe(-1);
expect(gridFocus.getCellTabindex(cells[0][1])).toBe(-1);
expect(gridFocus.getCellTabindex(cells[0][2])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][0])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][1])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][2])).toBe(-1);
});

it('should return 0 if focusMode is "roving" and cell is the activeCell', () => {
Expand All @@ -275,9 +275,9 @@ describe('GridFocus', () => {
focusMode: signal('roving'),
});

expect(gridFocus.getCellTabindex(cells[0][0])).toBe(0);
expect(gridFocus.getCellTabindex(cells[0][1])).toBe(-1);
expect(gridFocus.getCellTabindex(cells[0][2])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][0])).toBe(0);
expect(gridFocus.getCellTabIndex(cells[0][1])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][2])).toBe(-1);
});
});

Expand Down
8 changes: 4 additions & 4 deletions src/aria/private/behaviors/grid-focus/grid-focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ export class GridFocus<T extends GridFocusCell> {
return gridCells.length === 0 || gridCells.every(row => row.every(cell => cell.disabled()));
}

/** The tabindex for the grid container. */
getGridTabindex(): -1 | 0 {
/** The tab index for the grid container. */
getGridTabIndex(): -1 | 0 {
if (this.isGridDisabled()) {
return 0;
}
return this.inputs.focusMode() === 'activedescendant' ? 0 : -1;
}

/** Returns the tabindex for the given grid cell cell. */
getCellTabindex(cell: T): -1 | 0 {
/** Returns the tab index for the given grid cell cell. */
getCellTabIndex(cell: T): -1 | 0 {
if (this.isGridDisabled()) {
return -1;
}
Expand Down
12 changes: 6 additions & 6 deletions src/aria/private/behaviors/grid/grid-focus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ describe('GridFocus', () => {

gridFocus.focusCell(cells[1][1]);

expect(gridFocus.getCellTabindex(cells[1][1])).toBe(0);
expect(gridFocus.getCellTabIndex(cells[1][1])).toBe(0);
});

it('should return -1 for inactive cells in roving mode', () => {
Expand All @@ -231,8 +231,8 @@ describe('GridFocus', () => {

gridFocus.focusCell(cells[1][1]);

expect(gridFocus.getCellTabindex(cells[0][0])).toBe(-1);
expect(gridFocus.getCellTabindex(cells[2][2])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][0])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[2][2])).toBe(-1);
});

it('should return -1 for all cells in activedescendant mode', () => {
Expand All @@ -243,14 +243,14 @@ describe('GridFocus', () => {

gridFocus.focusCell(cells[1][1]);

expect(gridFocus.getCellTabindex(cells[0][0])).toBe(-1);
expect(gridFocus.getCellTabindex(cells[1][1])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[0][0])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[1][1])).toBe(-1);
});

it('should return -1 for all cells when the grid is disabled', () => {
const cells = createTestGrid(createGridA);
const gridFocus = setupGridFocus(signal(cells), {disabled: signal(true)});
expect(gridFocus.getCellTabindex(cells[1][1])).toBe(-1);
expect(gridFocus.getCellTabIndex(cells[1][1])).toBe(-1);
});
});

Expand Down
6 changes: 3 additions & 3 deletions src/aria/private/behaviors/grid/grid-focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class GridFocus<T extends GridFocusCell> {
return gridCells.length === 0 || gridCells.every(row => row.every(cell => cell.disabled()));
});

/** The tabindex for the grid container. */
/** The tab index for the grid container. */
readonly gridTabIndex = computed<-1 | 0>(() => {
if (this.gridDisabled()) {
return 0;
Expand All @@ -105,8 +105,8 @@ export class GridFocus<T extends GridFocusCell> {

constructor(readonly inputs: GridFocusInputs & GridFocusDeps<T>) {}

/** Returns the tabindex for the given grid cell cell. */
getCellTabindex(cell: T): -1 | 0 {
/** Returns the tab index for the given grid cell cell. */
getCellTabIndex(cell: T): -1 | 0 {
if (this.gridDisabled()) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/aria/private/behaviors/grid/grid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Grid', () => {
});

describe('cellTabIndex', () => {
it('should return the tabindex for a cell', () => {
it('should return the tab index for a cell', () => {
const cells = createTestGrid(createGridA);
const grid = setupGrid(signal(cells));

Expand Down
6 changes: 3 additions & 3 deletions src/aria/private/behaviors/grid/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Grid<T extends GridCell> {
/** The anchor point for range selection, linked to the active coordinates. */
readonly selectionAnchor = linkedSignal<RowCol>(() => this.focusBehavior.activeCoords());

/** The `tabindex` for the grid container. */
/** The `tab index` for the grid container. */
readonly gridTabIndex = computed(() => this.focusBehavior.gridTabIndex());

/** Whether the grid is in a disabled state. */
Expand Down Expand Up @@ -84,9 +84,9 @@ export class Grid<T extends GridCell> {
return index !== undefined ? index + 1 : undefined;
}

/** Gets the `tabindex` for a given cell. */
/** Gets the `tab index` for a given cell. */
cellTabIndex(cell: T): -1 | 0 {
return this.focusBehavior.getCellTabindex(cell);
return this.focusBehavior.getCellTabIndex(cell);
}

/** Navigates to the cell above the currently active cell. */
Expand Down
34 changes: 17 additions & 17 deletions src/aria/private/behaviors/list-focus/list-focus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ describe('List Focus', () => {
focusManager = getListFocus({focusMode: signal('roving')});
});

it('should set the list tabindex to -1', () => {
expect(focusManager.getListTabindex()).toBe(-1);
it('should set the list to -1', () => {
expect(focusManager.getListTabIndex()).toBe(-1);
});

it('should set the activedescendant to undefined', () => {
it('should set the active descendant to undefined', () => {
expect(focusManager.getActiveDescendant()).toBeUndefined();
});

it('should set the tabindex based on the active index', () => {
it('should set the tab index based on the active index', () => {
const items = focusManager.inputs.items() as TestItem[];
focusManager.inputs.activeItem.set(focusManager.inputs.items()[2]);
expect(focusManager.getItemTabindex(items[0])).toBe(-1);
expect(focusManager.getItemTabindex(items[1])).toBe(-1);
expect(focusManager.getItemTabindex(items[2])).toBe(0);
expect(focusManager.getItemTabindex(items[3])).toBe(-1);
expect(focusManager.getItemTabindex(items[4])).toBe(-1);
expect(focusManager.getItemTabIndex(items[0])).toBe(-1);
expect(focusManager.getItemTabIndex(items[1])).toBe(-1);
expect(focusManager.getItemTabIndex(items[2])).toBe(0);
expect(focusManager.getItemTabIndex(items[3])).toBe(-1);
expect(focusManager.getItemTabIndex(items[4])).toBe(-1);
});
});

Expand All @@ -77,22 +77,22 @@ describe('List Focus', () => {
focusManager = getListFocus({focusMode: signal('activedescendant')});
});

it('should set the list tabindex to 0', () => {
expect(focusManager.getListTabindex()).toBe(0);
it('should set the list tab index to 0', () => {
expect(focusManager.getListTabIndex()).toBe(0);
});

it('should set the activedescendant to the active items id', () => {
expect(focusManager.getActiveDescendant()).toBe(focusManager.inputs.items()[0].id());
});

it('should set the tabindex of all items to -1', () => {
it('should set the tab index of all items to -1', () => {
const items = focusManager.inputs.items() as TestItem[];
focusManager.inputs.activeItem.set(focusManager.inputs.items()[0]);
expect(focusManager.getItemTabindex(items[0])).toBe(-1);
expect(focusManager.getItemTabindex(items[1])).toBe(-1);
expect(focusManager.getItemTabindex(items[2])).toBe(-1);
expect(focusManager.getItemTabindex(items[3])).toBe(-1);
expect(focusManager.getItemTabindex(items[4])).toBe(-1);
expect(focusManager.getItemTabIndex(items[0])).toBe(-1);
expect(focusManager.getItemTabIndex(items[1])).toBe(-1);
expect(focusManager.getItemTabIndex(items[2])).toBe(-1);
expect(focusManager.getItemTabIndex(items[3])).toBe(-1);
expect(focusManager.getItemTabIndex(items[4])).toBe(-1);
});

it('should update the activedescendant of the list when navigating', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/aria/private/behaviors/list-focus/list-focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ export class ListFocus<T extends ListFocusItem> {
return this.inputs.activeItem()?.id() ?? undefined;
}

/** The tabindex for the list. */
getListTabindex(): -1 | 0 {
/** The tab index for the list. */
getListTabIndex(): -1 | 0 {
if (this.isListDisabledFocusable()) {
return 0;
}
return this.inputs.focusMode() === 'activedescendant' ? 0 : -1;
}

/** Returns the tabindex for the given item. */
getItemTabindex(item: T): -1 | 0 {
/** Returns the tab index for the given item. */
getItemTabIndex(item: T): -1 | 0 {
if (this.isListDisabledFocusable()) {
return -1;
}
Expand Down
24 changes: 12 additions & 12 deletions src/aria/private/behaviors/list/list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,36 @@ describe('List Behavior', () => {
}

describe('with focusMode: "activedescendant"', () => {
it('should set the list tabindex to 0', () => {
it('should set the list tab index to 0', () => {
const {list} = getDefaultPatterns({focusMode: signal('activedescendant')});
expect(list.tabindex()).toBe(0);
expect(list.tabIndex()).toBe(0);
});

it('should set the active descendant to the active item id', () => {
const {list} = getDefaultPatterns({focusMode: signal('activedescendant')});
expect(list.activedescendant()).toBe('item-0');
expect(list.activeDescendant()).toBe('item-0');
list.next();
expect(list.activedescendant()).toBe('item-1');
expect(list.activeDescendant()).toBe('item-1');
});

it('should set item tabindex to -1', () => {
it('should set item tab index to -1', () => {
const {list, items} = getDefaultPatterns({focusMode: signal('activedescendant')});
expect(list.getItemTabindex(items[0])).toBe(-1);
});
});

describe('with focusMode: "roving"', () => {
it('should set the list tabindex to -1', () => {
it('should set the list tab index to -1', () => {
const {list} = getDefaultPatterns({focusMode: signal('roving')});
expect(list.tabindex()).toBe(-1);
expect(list.tabIndex()).toBe(-1);
});

it('should not set the active descendant', () => {
const {list} = getDefaultPatterns({focusMode: signal('roving')});
expect(list.activedescendant()).toBeUndefined();
expect(list.activeDescendant()).toBeUndefined();
});

it('should set the active item tabindex to 0 and others to -1', () => {
it('should set the active item tab index to 0 and others to -1', () => {
const {list, items} = getDefaultPatterns({focusMode: signal('roving')});
expect(list.getItemTabindex(items[0])).toBe(0);
expect(list.getItemTabindex(items[1])).toBe(-1);
Expand Down Expand Up @@ -140,8 +140,8 @@ describe('List Behavior', () => {
expect(list.inputs.value()).toEqual([]);
});

it('should have a tabindex of 0', () => {
expect(list.tabindex()).toBe(0);
it('should have a tab index of 0', () => {
expect(list.tabIndex()).toBe(0);
});
});

Expand Down Expand Up @@ -171,7 +171,7 @@ describe('List Behavior', () => {
});

it('should have a tabindex of 0', () => {
expect(list.tabindex()).toBe(-1);
expect(list.tabIndex()).toBe(-1);
});
});

Expand Down
Loading
Loading