MCPcopy Index your code
hub / github.com/adobe/react-spectrum / findTab

Method findTab

packages/@react-aria/test-utils/src/tabs.ts:63–75  ·  view source on GitHub ↗

* Returns a tab matching the specified index or text content.

(opts: {indexOrText: number | string})

Source from the content-addressed store, hash-verified

61 * Returns a tab matching the specified index or text content.
62 */
63 findTab(opts: {indexOrText: number | string}): HTMLElement {
64 let {indexOrText} = opts;
65
66 let tab;
67 let tabs = this.getTabs();
68 if (typeof indexOrText === 'number') {
69 tab = tabs[indexOrText];
70 } else if (typeof indexOrText === 'string') {
71 tab = within(this._tablist).getByText(indexOrText).closest('[role=tab]')! as HTMLElement;
72 }
73
74 return tab;
75 }
76
77 private async keyboardNavigateToTab(opts: {tab: HTMLElement; orientation?: Orientation}) {
78 let {tab, orientation = 'vertical'} = opts;

Callers 2

triggerTabMethod · 0.95
Tabs.test.jsFile · 0.80

Calls 1

getTabsMethod · 0.95

Tested by

no test coverage detected