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

Method close

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

* Closes the select.

()

Source from the content-addressed store, hash-verified

105 * Closes the select.
106 */
107 async close(): Promise<void> {
108 let listbox = this.getListbox();
109 if (listbox) {
110 act(() => listbox.focus());
111 await this.user.keyboard('[Escape]');
112 }
113
114 await waitFor(() => {
115 if (document.activeElement !== this._trigger) {
116 throw new Error(
117 `Expected the document.activeElement after closing the select dropdown to be the select component trigger but got ${document.activeElement}`
118 );
119 } else {
120 return true;
121 }
122 });
123
124 if (listbox && document.contains(listbox)) {
125 throw new Error(
126 'Expected the select element listbox to not be in the document after closing the dropdown.'
127 );
128 }
129 }
130
131 /**
132 * Returns a option matching the specified index or text content.

Callers

nothing calls this directly

Calls 3

getListboxMethod · 0.95
actFunction · 0.90
focusMethod · 0.80

Tested by

no test coverage detected