Skip to content

Commit

Permalink
Merge pull request #5210 from mozilla/dependabot/npm_and_yarn/react-a…
Browse files Browse the repository at this point in the history
…ria-3.36.0

Bump react-aria from 3.35.1 to 3.36.0
  • Loading branch information
groovecoder authored Nov 26, 2024
2 parents 667a829 + 9b56564 commit 05fd10e
Show file tree
Hide file tree
Showing 6 changed files with 1,009 additions and 966 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"cldr-localenames-modern": "^45.0.0",
"msw": "^2.6.6",
"react": "18.3.1",
"react-aria": "^3.35.1",
"react-aria": "^3.36.0",
"react-confetti": "^6.1.0",
"react-dom": "18.3.1",
"react-ga": "^3.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,22 @@ import {
FocusScope,
useOverlay,
useMenuTrigger,
useMenu,
DismissButton,
mergeProps,
useMenuItem,
useFocus,
useButton,
AriaOverlayProps,
} from "react-aria";
import { AriaMenuItemProps } from "@react-aria/menu";
import {
Item,
MenuTriggerState,
TreeProps,
TreeState,
useMenuTriggerState,
useOverlayTriggerState,
useTreeState,
} from "react-stately";
import {
HTMLAttributes,
Key,
ReactNode,
useEffect,
useRef,
useState,
} from "react";
import { Key, ReactNode, useEffect, useRef, useState } from "react";
import styles from "./AliasGenerationButton.module.scss";
import { ArrowDownIcon, PlusIcon } from "../../Icons";
import { ProfileData } from "../../../hooks/api/profile";
Expand All @@ -41,6 +31,7 @@ import { CustomAddressGenerationModal } from "./CustomAddressGenerationModal";
import { useGaEvent } from "../../../hooks/gaEvent";
import { useL10n } from "../../../hooks/l10n";
import { isFlagActive } from "../../../functions/waffle";
import { MenuPopupProps, useMenu } from "../../../hooks/menu";
import { AddressPickerModal } from "./AddressPickerModal";

export type Props = {
Expand Down Expand Up @@ -301,12 +292,7 @@ const AliasTypeMenuButton = (props: AliasTypeMenuButtonProps) => {
);
};

type AliasTypeMenuPopupProps = TreeProps<Record<string, never>> & {
onAction: AriaMenuItemProps["onAction"];
domProps: HTMLAttributes<HTMLElement>;
onClose?: AriaOverlayProps["onClose"];
autoFocus?: MenuTriggerState["focusStrategy"];
};
type AliasTypeMenuPopupProps = MenuPopupProps<Record<string, never>>;
const AliasTypeMenuPopup = (props: AliasTypeMenuPopupProps) => {
const popupState = useTreeState({ ...props, selectionMode: "none" });

Expand Down
21 changes: 3 additions & 18 deletions frontend/src/components/layout/navigation/AppPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,19 @@ import {
useTreeState,
TreeProps,
TreeState,
MenuTriggerState,
Item,
} from "react-stately";
import {
useMenuTrigger,
useButton,
useMenu,
useOverlay,
FocusScope,
DismissButton,
mergeProps,
useMenuItem,
useFocus,
AriaOverlayProps,
} from "react-aria";
import {
HTMLAttributes,
Key,
ReactNode,
useRef,
useState,
useEffect,
RefObject,
} from "react";
import { Key, ReactNode, useRef, useState, useEffect, RefObject } from "react";
import { AriaMenuItemProps } from "@react-aria/menu";
import styles from "./AppPicker.module.scss";
import FirefoxLogo from "../images/fx.png";
Expand All @@ -41,6 +30,7 @@ import { BentoIcon } from "../../Icons";
import Image from "../../Image";
import { useGaEvent } from "../../../hooks/gaEvent";
import { useL10n } from "../../../hooks/l10n";
import { MenuPopupProps, useMenu } from "../../../hooks/menu";

const getProducts = (referringSiteUrl: string) => ({
monitor: {
Expand Down Expand Up @@ -302,12 +292,7 @@ const AppPickerTrigger = ({
);
};

type AppPickerPopupProps = TreeProps<Record<string, never>> & {
onAction: AriaMenuItemProps["onAction"];
domProps: HTMLAttributes<HTMLElement>;
onClose?: AriaOverlayProps["onClose"];
autoFocus?: MenuTriggerState["focusStrategy"];
};
type AppPickerPopupProps = MenuPopupProps<Record<string, never>>;
const AppPickerPopup = (props: AppPickerPopupProps) => {
const l10n = useL10n();
const popupState = useTreeState({ ...props, selectionMode: "none" });
Expand Down
13 changes: 3 additions & 10 deletions frontend/src/components/layout/navigation/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@ import {
useTreeState,
TreeProps,
TreeState,
MenuTriggerState,
Item,
} from "react-stately";
import {
useMenuTrigger,
useButton,
useMenu,
useOverlay,
FocusScope,
DismissButton,
mergeProps,
useMenuItem,
useFocus,
AriaOverlayProps,
} from "react-aria";
import { HTMLAttributes, Key, ReactNode, useRef, useState } from "react";
import { Key, ReactNode, useRef, useState } from "react";
import { AriaMenuItemProps } from "@react-aria/menu";
import Link from "next/link";
import styles from "./UserMenu.module.scss";
Expand All @@ -37,6 +34,7 @@ import { useRuntimeData } from "../../../hooks/api/runtimeData";
import { setCookie } from "../../../functions/cookies";
import { useGaEvent } from "../../../hooks/gaEvent";
import { useL10n } from "../../../hooks/l10n";
import { MenuPopupProps, useMenu } from "../../../hooks/menu";

export type Props = {
style: string;
Expand Down Expand Up @@ -266,12 +264,7 @@ const UserMenuTrigger = ({
);
};

type UserMenuPopupProps = TreeProps<Record<string, never>> & {
onAction: AriaMenuItemProps["onAction"];
domProps: HTMLAttributes<HTMLElement>;
onClose?: AriaOverlayProps["onClose"];
autoFocus?: MenuTriggerState["focusStrategy"];
};
type UserMenuPopupProps = MenuPopupProps<Record<string, never>>;
const UserMenuPopup = (props: UserMenuPopupProps) => {
const popupState = useTreeState({ ...props, selectionMode: "none" });

Expand Down
31 changes: 31 additions & 0 deletions frontend/src/hooks/menu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { AriaOverlayProps, useMenu as useAriaMenu } from "react-aria";
import { AriaMenuItemProps, AriaMenuOptions, MenuAria } from "@react-aria/menu";
import { MenuTriggerState, TreeProps, TreeState } from "react-stately";
import { RefObject } from "@react-types/shared";
import { HTMLAttributes } from "react";

// MenuTriggerState focusStrategy from react-stately 3.34.0 is typed as
// FocusStrategy | null
// In react-aria 3.36.0, autoFocus is typed as
// boolean | FocusStrategy | undefined
// So, adjust a null value into undefined for use in react-aria
// Presumably, react-aria will reconcile its typings with react-stately
// at some point, at which point this commit can be reverted again.
export type MenuPopupProps<T> = TreeProps<T> & {
onAction: AriaMenuItemProps["onAction"];
domProps: HTMLAttributes<HTMLElement>;
onClose?: AriaOverlayProps["onClose"];
autoFocus?: MenuTriggerState["focusStrategy"] | null;
};

export function useMenu<T>(
props: MenuPopupProps<T>,
state: TreeState<T>,
ref: RefObject<HTMLElement | null>,
): MenuAria {
const adjustedProps: AriaMenuOptions<T> = {
...props,
autoFocus: props.autoFocus ?? undefined,
};
return useAriaMenu(adjustedProps, state, ref);
}
Loading

0 comments on commit 05fd10e

Please sign in to comment.