Repository: adobe/react-spectrum
File: packages/@react-aria/menu/src/useMenuItem.ts (TypeScript)

Code before:
      // Hovering over an already expanded sub dialog trigger should keep focus in the dialog.
      if (!isFocusVisible() && !(isTriggerExpanded && hasPopup)) {
        selectionManager.setFocused(true);
        selectionManager.setFocusedKey(key);
      }
      hoverStartProp?.(e);
    },
    onHoverChange,
    onHoverEnd
  });

  let {keyboardProps} = useKeyboard({
    onKeyDown: (e) => {
      // Ignore repeating events, which may have started on the menu trigger before moving
      // focus to the menu item. We want to wait for a second complete key press sequence.
      if (e.repeat) {
        e.continuePropagation();
        return;
      }

      switch (e.key) {
        case ' ':
          interaction.current = {pointerType: 'keyboard', key: ' '};
          (getEventTarget(e) as HTMLElement).click();

          // click above sets modality to "virutal", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
          // to the newly opened submenu's first item.
          setInteractionModality('keyboard');
          break;
        case 'Enter':
          interaction.current = {pointerType: 'keyboard', key: 'Enter'};

          // Trigger click unless this is a link. Links trigger click natively.
          if ((getEventTarget(e) as HTMLElement).tagName !== 'A') {
            (getEventTarget(e) as HTMLElement).click();
          }

          // click above sets modality to "virutal", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
          // to the newly opened submenu's first item.
          setInteractionModality('keyboard');
          break;
        default:
          if (!isTrigger) {
            e.continuePropagation();
          }

          onKeyDown?.(e);
          break;
      }
    },
    onKeyUp

Review comment (suggestion):
```suggestion
          // click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
```

Code after:
      // Hovering over an already expanded sub dialog trigger should keep focus in the dialog.
      if (!isFocusVisible() && !(isTriggerExpanded && hasPopup)) {
        selectionManager.setFocused(true);
        selectionManager.setFocusedKey(key);
      }
      hoverStartProp?.(e);
    },
    onHoverChange,
    onHoverEnd
  });

  let {keyboardProps} = useKeyboard({
    onKeyDown: (e) => {
      // Ignore repeating events, which may have started on the menu trigger before moving
      // focus to the menu item. We want to wait for a second complete key press sequence.
      if (e.repeat) {
        e.continuePropagation();
        return;
      }

      switch (e.key) {
        case ' ':
          interaction.current = {pointerType: 'keyboard', key: ' '};
          (getEventTarget(e) as HTMLElement).click();

          // click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
          // to the newly opened submenu's first item.
          setInteractionModality('keyboard');
          break;
        case 'Enter':
          interaction.current = {pointerType: 'keyboard', key: 'Enter'};

          // Trigger click unless this is a link. Links trigger click natively.
          if ((getEventTarget(e) as HTMLElement).tagName !== 'A') {
            (getEventTarget(e) as HTMLElement).click();
          }

          // click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
          // to the newly opened submenu's first item.
          setInteractionModality('keyboard');
          break;
        default:
          if (!isTrigger) {
            e.continuePropagation();
          }

          onKeyDown?.(e);
          break;
      }
    },
    onKeyUp