Skip to content

Commit b893da1

Browse files
committed
feat(aria/tabs): Add accessors for pattern properties
1 parent e709fd4 commit b893da1

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

src/aria/tabs/tabs.ts

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ export class Tabs {
120120
host: {
121121
'role': 'tablist',
122122
'class': 'ng-tablist',
123-
'[attr.tabindex]': '_pattern.tabindex()',
124-
'[attr.aria-disabled]': '_pattern.disabled()',
125-
'[attr.aria-orientation]': '_pattern.orientation()',
126-
'[attr.aria-activedescendant]': '_pattern.activedescendant()',
123+
'[attr.tabindex]': 'tabindex()',
124+
'[attr.aria-disabled]': 'disabled()',
125+
'[attr.aria-orientation]': 'orientation()',
126+
'[attr.aria-activedescendant]': 'activedescendant()',
127127
'(keydown)': '_pattern.onKeydown($event)',
128128
'(pointerdown)': '_pattern.onPointerdown($event)',
129129
'(focusin)': 'onFocus()',
@@ -173,6 +173,15 @@ export class TabList implements OnInit, OnDestroy {
173173
/** The current selected tab. */
174174
readonly selectedTab = model<string | undefined>();
175175

176+
/** The id of the current active tab. */
177+
readonly activedescendant = computed(() => this._pattern.activedescendant());
178+
179+
/** Whether selection should follow focus. */
180+
readonly followFocus = computed(() => this._pattern.followFocus());
181+
182+
/** The tabindex of the tablist. */
183+
readonly tabindex = computed(() => this._pattern.tabindex());
184+
176185
/** The TabList UIPattern. */
177186
readonly _pattern: TabListPattern = new TabListPattern({
178187
...this,
@@ -225,11 +234,11 @@ export class TabList implements OnInit, OnDestroy {
225234
host: {
226235
'role': 'tab',
227236
'class': 'ng-tab',
228-
'[attr.data-active]': '_pattern.active()',
237+
'[attr.data-active]': 'active()',
229238
'[attr.id]': '_pattern.id()',
230-
'[attr.tabindex]': '_pattern.tabindex()',
231-
'[attr.aria-selected]': '_pattern.selected()',
232-
'[attr.aria-disabled]': '_pattern.disabled()',
239+
'[attr.tabindex]': 'tabindex()',
240+
'[attr.aria-selected]': 'selected()',
241+
'[attr.aria-disabled]': 'disabled()',
233242
'[attr.aria-controls]': '_pattern.controls()',
234243
},
235244
})
@@ -263,6 +272,18 @@ export class Tab implements HasElement, OnInit, OnDestroy {
263272
/** A local unique identifier for the tab. */
264273
readonly value = input.required<string>();
265274

275+
/** Whether the tab is active. */
276+
readonly active = computed(() => this._pattern.active());
277+
278+
/** Whether the tab is expanded. */
279+
readonly expanded = computed(() => this._pattern.expanded());
280+
281+
/** Whether the tab is selected. */
282+
readonly selected = computed(() => this._pattern.selected());
283+
284+
/** The tabindex of the tab. */
285+
readonly tabindex = computed(() => this._pattern.tabindex());
286+
266287
/** The Tab UIPattern. */
267288
readonly _pattern: TabPattern = new TabPattern({
268289
...this,
@@ -296,8 +317,8 @@ export class Tab implements HasElement, OnInit, OnDestroy {
296317
'role': 'tabpanel',
297318
'class': 'ng-tabpanel',
298319
'[attr.id]': '_pattern.id()',
299-
'[attr.tabindex]': '_pattern.tabindex()',
300-
'[attr.inert]': '_pattern.hidden() ? true : null',
320+
'[attr.tabindex]': 'tabindex()',
321+
'[attr.inert]': 'hidden() ? true : null',
301322
'[attr.aria-labelledby]': '_pattern.labelledBy()',
302323
},
303324
hostDirectives: [
@@ -323,6 +344,12 @@ export class TabPanel implements OnInit, OnDestroy {
323344
/** A local unique identifier for the tabpanel. */
324345
readonly value = input.required<string>();
325346

347+
/** Whether the tab panel is hidden. */
348+
readonly hidden = computed(() => this._pattern.hidden());
349+
350+
/** The tabindex of the tab panel. */
351+
readonly tabindex = computed(() => this._pattern.tabindex());
352+
326353
/** The TabPanel UIPattern. */
327354
readonly _pattern: TabPanelPattern = new TabPanelPattern({
328355
...this,

0 commit comments

Comments
 (0)