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

Method findOption

packages/@react-aria/test-utils/src/select.ts:134–148  ·  view source on GitHub ↗

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

(opts: {indexOrText: number | string})

Source from the content-addressed store, hash-verified

132 * Returns a option matching the specified index or text content.
133 */
134 findOption(opts: {indexOrText: number | string}): HTMLElement {
135 let {indexOrText} = opts;
136
137 let option;
138 let options = this.getOptions();
139 let listbox = this.getListbox();
140
141 if (typeof indexOrText === 'number') {
142 option = options[indexOrText];
143 } else if (typeof indexOrText === 'string' && listbox != null) {
144 option = within(listbox!).getByText(indexOrText).closest('[role=option]')! as HTMLElement;
145 }
146
147 return option;
148 }
149
150 private async keyboardNavigateToOption(opts: {option: HTMLElement}) {
151 let {option} = opts;

Callers 1

toggleOptionSelectionMethod · 0.95

Calls 2

getOptionsMethod · 0.95
getListboxMethod · 0.95

Tested by

no test coverage detected