Skip to content

Commit 5cedd1a

Browse files
committed
refactor(aria/tabs): Add accessors for pattern properties
1 parent 0fc90c8 commit 5cedd1a

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/aria/tabs/tabs.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ export class Tabs {
122122
'class': 'ng-tablist',
123123
'[attr.tabindex]': '_pattern.tabindex()',
124124
'[attr.aria-disabled]': '_pattern.disabled()',
125-
'[attr.aria-orientation]': '_pattern.orientation()',
126-
'[attr.aria-activedescendant]': '_pattern.activedescendant()',
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,12 @@ 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+
176182
/** The TabList UIPattern. */
177183
readonly _pattern: TabListPattern = new TabListPattern({
178184
...this,
@@ -225,10 +231,10 @@ export class TabList implements OnInit, OnDestroy {
225231
host: {
226232
'role': 'tab',
227233
'class': 'ng-tab',
228-
'[attr.data-active]': '_pattern.active()',
234+
'[attr.data-active]': 'active()',
229235
'[attr.id]': '_pattern.id()',
230236
'[attr.tabindex]': '_pattern.tabindex()',
231-
'[attr.aria-selected]': '_pattern.selected()',
237+
'[attr.aria-selected]': 'selected()',
232238
'[attr.aria-disabled]': '_pattern.disabled()',
233239
'[attr.aria-controls]': '_pattern.controls()',
234240
},
@@ -263,6 +269,15 @@ export class Tab implements HasElement, OnInit, OnDestroy {
263269
/** A local unique identifier for the tab. */
264270
readonly value = input.required<string>();
265271

272+
/** Whether the tab is active. */
273+
readonly active = computed(() => this._pattern.active());
274+
275+
/** Whether the tab is expanded. */
276+
readonly expanded = computed(() => this._pattern.expanded());
277+
278+
/** Whether the tab is selected. */
279+
readonly selected = computed(() => this._pattern.selected());
280+
266281
/** The Tab UIPattern. */
267282
readonly _pattern: TabPattern = new TabPattern({
268283
...this,
@@ -297,7 +312,7 @@ export class Tab implements HasElement, OnInit, OnDestroy {
297312
'class': 'ng-tabpanel',
298313
'[attr.id]': '_pattern.id()',
299314
'[attr.tabindex]': '_pattern.tabindex()',
300-
'[attr.inert]': '_pattern.hidden() ? true : null',
315+
'[attr.inert]': 'hidden() ? true : null',
301316
'[attr.aria-labelledby]': '_pattern.labelledBy()',
302317
},
303318
hostDirectives: [
@@ -323,6 +338,9 @@ export class TabPanel implements OnInit, OnDestroy {
323338
/** A local unique identifier for the tabpanel. */
324339
readonly value = input.required<string>();
325340

341+
/** Whether the tab panel is hidden. */
342+
readonly hidden = computed(() => this._pattern.hidden());
343+
326344
/** The TabPanel UIPattern. */
327345
readonly _pattern: TabPanelPattern = new TabPanelPattern({
328346
...this,

0 commit comments

Comments
 (0)