Skip to content

Commit ff022d2

Browse files
committed
refactor(aria): change grid tabIndex input to tabbable boolean
1 parent 77367c3 commit ff022d2

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/aria/grid/grid.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ export class Grid {
125125
/** Whether enable range selections (with modifier keys or dragging). */
126126
readonly enableRangeSelection = input(false, {transform: booleanAttribute});
127127

128-
/** Overrides the default tab index of the grid. */
129-
readonly tabIndex = input<number | undefined>(undefined);
128+
/** Whether the grid is tabbable. */
129+
readonly tabbable = input<boolean | undefined>(undefined);
130130

131131
/** The UI pattern for the grid. */
132132
readonly _pattern = new GridPattern({

src/aria/private/behaviors/grid/grid-focus.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export interface GridFocusInputs {
3232
/** Whether disabled cells in the grid should be focusable. */
3333
softDisabled: SignalLike<boolean>;
3434

35-
/** Overrides the default tab index of the grid. */
36-
tabIndex?: SignalLike<number | undefined>;
35+
/** Whether the grid is tabbable. */
36+
tabbable?: SignalLike<boolean | undefined>;
3737
}
3838

3939
/** Dependencies for the `GridFocus` class. */
@@ -98,10 +98,13 @@ export class GridFocus<T extends GridFocusCell> {
9898
});
9999

100100
/** The tab index for the grid container. */
101-
readonly gridTabIndex = computed<-1 | 0>(() => {
102-
const tabIndexOverride = this.inputs.tabIndex?.();
103-
if (tabIndexOverride !== undefined && tabIndexOverride !== null) {
104-
return (tabIndexOverride === -1 ? -1 : 0) as -1 | 0;
101+
readonly gridTabIndex = computed<-1 | 0 | null>(() => {
102+
const isTabbable = this.inputs.tabbable?.();
103+
if (isTabbable === false) {
104+
return -1;
105+
}
106+
if (isTabbable === true) {
107+
return 0;
105108
}
106109

107110
if (this.gridDisabled()) {

src/aria/private/behaviors/grid/grid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class Grid<T extends GridCell> {
8383
);
8484

8585
/** The tab index for the grid container. */
86-
readonly gridTabIndex: SignalLike<-1 | 0> = () => this.focusBehavior.gridTabIndex();
86+
readonly gridTabIndex: SignalLike<-1 | 0 | null> = () => this.focusBehavior.gridTabIndex();
8787

8888
/** Whether the grid is in a disabled state. */
8989
readonly gridDisabled: SignalLike<boolean> = () => this.focusBehavior.gridDisabled();

0 commit comments

Comments
 (0)