From 06cd73286f3090db93da90f9b0f826869e68dc1f Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Thu, 9 Feb 2023 13:53:39 +0100 Subject: [PATCH] Immediately close realm selector when navigation starts (#4359) --- .../realm-selector/RealmSelector.tsx | 63 +++++++++++-------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/apps/admin-ui/src/components/realm-selector/RealmSelector.tsx b/apps/admin-ui/src/components/realm-selector/RealmSelector.tsx index 42eba60e21..8ca2e9b50e 100644 --- a/apps/admin-ui/src/components/realm-selector/RealmSelector.tsx +++ b/apps/admin-ui/src/components/realm-selector/RealmSelector.tsx @@ -2,6 +2,7 @@ import { Button, ContextSelector, ContextSelectorItem, + ContextSelectorItemProps, Divider, Dropdown, DropdownItem, @@ -12,9 +13,9 @@ import { SplitItem, } from "@patternfly/react-core"; import { CheckIcon } from "@patternfly/react-icons"; -import { Fragment, ReactElement, useState } from "react"; +import { Fragment, useState } from "react"; import { useTranslation } from "react-i18next"; -import { Link, useLocation, useNavigate } from "react-router-dom"; +import { Link, To, useHref } from "react-router-dom"; import { useRealm } from "../../context/realm-context/RealmContext"; import { useRealms } from "../../context/RealmsContext"; @@ -22,11 +23,14 @@ import { useRecentRealms } from "../../context/RecentRealms"; import { useWhoAmI } from "../../context/whoami/WhoAmI"; import { toDashboard } from "../../dashboard/routes/Dashboard"; import { toAddRealm } from "../../realm/routes/AddRealm"; -import { useUpdateEffect } from "../../utils/useUpdateEffect"; import "./realm-selector.css"; -const AddRealm = () => { +type AddRealmProps = { + onClick: () => void; +}; + +const AddRealm = ({ onClick }: AddRealmProps) => { const { realm } = useRealm(); const { t } = useTranslation("common"); @@ -34,6 +38,7 @@ const AddRealm = () => {