Skip to content

Commit 28fd2a0

Browse files
committed
refactor(aria/tabs): Extend public api with open methods
1 parent 1d9dcea commit 28fd2a0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/aria/tabs/tabs.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ export class Tabs {
112112
this._unorderedPanels.set(new Set(this._unorderedPanels()));
113113
}
114114
}
115+
116+
/** Opens the tab panel with the specified value. */
117+
open(value: string) {
118+
const tab = this._findTabPatternByValue(value);
119+
120+
tab?.expansion.open();
121+
}
122+
123+
_findTabPatternByValue(value: string) {
124+
return this.tabs()?.find(t => t.value() === value);
125+
}
115126
}
116127

117128
/**
@@ -277,6 +288,11 @@ export class Tab implements HasElement, OnInit, OnDestroy {
277288
value: this.value,
278289
});
279290

291+
/** Opens this tab panel. */
292+
open() {
293+
this._pattern.expansion.open();
294+
}
295+
280296
ngOnInit() {
281297
this._tabList.register(this);
282298
}

0 commit comments

Comments
 (0)