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

Code before:
      // 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
  });

  let {focusableProps} = useFocusable({onBlur, onFocus, onFocusChange}, ref);
  let domProps = filterDOMProps(item?.props);
  delete domProps.id;
  let linkProps = useLinkProps(item?.props);

  return {
    menuItemProps: {
      ...ariaProps,
      ...mergeProps(
        domProps,
        linkProps,

Review comment (suggestion):
```suggestion
          // 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.
```

Code after:
      // 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
  });

  let {focusableProps} = useFocusable({onBlur, onFocus, onFocusChange}, ref);
  let domProps = filterDOMProps(item?.props);
  delete domProps.id;
  let linkProps = useLinkProps(item?.props);

  return {
    menuItemProps: {
      ...ariaProps,
      ...mergeProps(
        domProps,
        linkProps,