Skip to content

Commit 6bb65a6

Browse files
committed
refactor(aria/tabs): Add accessors for pattern properties
1 parent 88f364c commit 6bb65a6

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/aria/tabs/tabs.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ export class TabList implements OnInit, OnDestroy {
230230
host: {
231231
'role': 'tab',
232232
'class': 'ng-tab',
233-
'[attr.data-active]': '_pattern.active()',
233+
'[attr.data-active]': 'active()',
234234
'[attr.id]': '_pattern.id()',
235235
'[attr.tabindex]': '_pattern.tabIndex()',
236-
'[attr.aria-selected]': '_pattern.selected()',
236+
'[attr.aria-selected]': 'selected()',
237237
'[attr.aria-disabled]': '_pattern.disabled()',
238238
'[attr.aria-controls]': '_pattern.controls()',
239239
},
@@ -268,6 +268,15 @@ export class Tab implements HasElement, OnInit, OnDestroy {
268268
/** A local unique identifier for the tab. */
269269
readonly value = input.required<string>();
270270

271+
/** Whether the tab is active. */
272+
readonly active = computed(() => this._pattern.active());
273+
274+
/** Whether the tab is expanded. */
275+
readonly expanded = computed(() => this._pattern.expanded());
276+
277+
/** Whether the tab is selected. */
278+
readonly selected = computed(() => this._pattern.selected());
279+
271280
/** The Tab UIPattern. */
272281
readonly _pattern: TabPattern = new TabPattern({
273282
...this,
@@ -302,7 +311,7 @@ export class Tab implements HasElement, OnInit, OnDestroy {
302311
'class': 'ng-tabpanel',
303312
'[attr.id]': '_pattern.id()',
304313
'[attr.tabindex]': '_pattern.tabIndex()',
305-
'[attr.inert]': '_pattern.hidden() ? true : null',
314+
'[attr.inert]': '!visible() ? true : null',
306315
'[attr.aria-labelledby]': '_pattern.labelledBy()',
307316
},
308317
hostDirectives: [
@@ -328,6 +337,9 @@ export class TabPanel implements OnInit, OnDestroy {
328337
/** A local unique identifier for the tabpanel. */
329338
readonly value = input.required<string>();
330339

340+
/** Whether the tab panel is visible. */
341+
readonly visible = computed(() => !this._pattern.hidden());
342+
331343
/** The TabPanel UIPattern. */
332344
readonly _pattern: TabPanelPattern = new TabPanelPattern({
333345
...this,
@@ -336,7 +348,7 @@ export class TabPanel implements OnInit, OnDestroy {
336348
});
337349

338350
constructor() {
339-
afterRenderEffect(() => this._deferredContentAware.contentVisible.set(!this._pattern.hidden()));
351+
afterRenderEffect(() => this._deferredContentAware.contentVisible.set(this.visible()));
340352
}
341353

342354
ngOnInit() {

0 commit comments

Comments
 (0)