Repository: ionic-team/ionic-framework
File: core/src/components/menu/menu.tsx (TypeScript)

Code before:
   * This can be useful in a button handler for determining which button was
   * clicked to close the menu. Some examples include:
   * `"cancel"`, `"destructive"`, `"selected"`, and `"backdrop"`.
   */
  @Method()
  close(animated = true, role?: string): Promise<boolean> {
    return this.setOpen(false, animated, role);
  }

  /**
   * Toggles the menu. If the menu is already open, it will try to close, otherwise it will try to open it.
   * If the operation can't be completed successfully, it returns `false`.
   * 
   * @param animated If `true`, toggle the menu with animation. Defaults to `true`.
   */
  @Method()
  toggle(animated = true): Promise<boolean> {
    return this.setOpen(!this._isOpen, animated);
  }

  /**
   * Opens or closes the button.
   * If the operation can't be completed successfully, it returns `false`.
   * 
   * @param shouldOpen If `true`, attempt to open the menu.
   * @param animated If `true`, open or close the menu with animation. Defaults to `true`.
   * @param role The role of the element that is closing the menu.
   */
  @Method()
  setOpen(shouldOpen: boolean, animated = true, role?: string): Promise<boolean> {
    return menuController._setOpen(this, shouldOpen, animated, role);
  }

  private trapKeyboardFocus(ev: Event, doc: Document) {
    const target = ev.target as HTMLElement | null;

    if (!target) {
      return;
    }

    /**
     * If the target is inside the menu contents, let the browser
     * focus as normal and keep a log of the last focused element.
     */
    if (this.el.contains(target)) {
      this.lastFocus = target;
    } else {
      /**
       * Otherwise, we are about to have focus go out of the menu.
       * Wrap the focus to either the first or last element.
       */

Review comment (suggestion):
```suggestion
   * @param animated If `true`, the menu will animate when opening/closing. If `false`, the menu will open/close instantly without animation.
```

Code after:
   * @param animated If `true`, the menu will animate when closing. If `false`,
   * the menu will close instantly without animation. Defaults to `true`.
   * @param role The role of the element that is closing the menu.
   * This can be useful in a button handler for determining which button was
   * clicked to close the menu. Some examples include:
   * `"cancel"`, `"destructive"`, `"selected"`, and `"backdrop"`.
   */
  @Method()
  close(animated = true, role?: string): Promise<boolean> {
    return this.setOpen(false, animated, role);
  }

  /**
   * Toggles the menu. If the menu is already open, it will try to close,
   * otherwise it will try to open it.
   * If the operation can't be completed successfully, it returns `false`.
   *
   * @param animated If `true`, the menu will animate when opening/closing.
   * If `false`, the menu will open/close instantly without animation.
   * Defaults to `true`.
   */
  @Method()
  toggle(animated = true): Promise<boolean> {
    return this.setOpen(!this._isOpen, animated);
  }

  /**
   * Opens or closes the menu.
   * If the operation can't be completed successfully, it returns `false`.
   *
   * @param shouldOpen If `true`, the menu will open. If `false`, the menu
   * will close.
   * @param animated If `true`, the menu will animate when opening/closing.
   * If `false`, the menu will open/close instantly without animation.
   * @param role The role of the element that is closing the menu.
   */
  @Method()
  setOpen(shouldOpen: boolean, animated = true, role?: string): Promise<boolean> {
    return menuController._setOpen(this, shouldOpen, animated, role);
  }

  private trapKeyboardFocus(ev: Event, doc: Document) {
    const target = ev.target as HTMLElement | null;

    if (!target) {
      return;
    }

    /**
     * If the target is inside the menu contents, let the browser
     * focus as normal and keep a log of the last focused element.