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

Method close

packages/@react-aria/test-utils/src/menu.ts:400–420  ·  view source on GitHub ↗

* Closes the menu.

()

Source from the content-addressed store, hash-verified

398 * Closes the menu.
399 */
400 async close(): Promise<void> {
401 let menu = this.getMenu();
402 if (menu) {
403 act(() => menu.focus());
404 await this.user.keyboard('[Escape]');
405
406 await waitFor(() => {
407 if (document.activeElement !== this.getTrigger()) {
408 throw new Error(
409 `Expected the document.activeElement after closing the menu to be the menu trigger but got ${document.activeElement}`
410 );
411 } else {
412 return true;
413 }
414 });
415
416 if (document.contains(menu)) {
417 throw new Error('Expected the menu to not be in the document after closing it.');
418 }
419 }
420 }
421
422 /**
423 * Returns the menu's trigger.

Callers

nothing calls this directly

Calls 4

getMenuMethod · 0.95
getTriggerMethod · 0.95
actFunction · 0.90
focusMethod · 0.80

Tested by

no test coverage detected