Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Restore Tab navigation in the sidebar New collection dialog by removing the nested modal (#83502)

Anderson8e203fd8cda3
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarContainer.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarContainer.tsx
index 8843aafa00f..93bcab81600 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarContainer.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarContainer.tsx
@@ -28,7 +28,6 @@ import { logout } from "metabase/redux/auth";
import type { State } from "metabase/redux/store";
import { addUndo } from "metabase/redux/undo";
import type { To } from "metabase/router";
-import { Modal } from "metabase/ui";
import * as Urls from "metabase/urls";
import type { Collection, User } from "metabase-types/api";
@@ -181,21 +180,6 @@ function MainNavbarContainer({
const closeModal = useCallback(() => setModal(null), []);
- const renderModalContent = useCallback(() => {
- if (modal === "MODAL_NEW_COLLECTION") {
- return (
- <CreateCollectionModal
- onClose={closeModal}
- onCreate={(collection: Collection) => {
- closeModal();
- onChangeLocation(Urls.collection(collection));
- }}
- />
- );
- }
- return null;
- }, [modal, closeModal, onChangeLocation]);
-
if (error || databasesError) {
return <NavbarErrorView />;
}
@@ -223,15 +207,15 @@ function MainNavbarContainer({
showExternalCollectionsSection={showExternalCollectionsSection}
/>
- <Modal
- opened={Boolean(modal)}
- onClose={closeModal}
- size="lg"
- withCloseButton={false}
- padding={0}
- >
- {renderModalContent()}
- </Modal>
+ {modal === "MODAL_NEW_COLLECTION" && (
+ <CreateCollectionModal
+ onClose={closeModal}
+ onCreate={(collection: Collection) => {
+ closeModal();
+ onChangeLocation(Urls.collection(collection));
+ }}
+ />
+ )}
</>
);
}
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/tests/common.unit.spec.tsx b/frontend/src/metabase/nav/containers/MainNavbar/tests/common.unit.spec.tsx
index 62ff960ab8d..7d5a4fb3675 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/tests/common.unit.spec.tsx
@@ -1,6 +1,6 @@
import userEvent from "@testing-library/user-event";
-import { screen, within } from "__support__/ui";
+import { screen, waitFor, within } from "__support__/ui";
import { ROOT_COLLECTION } from "metabase/common/collections/constants";
import { dayjs } from "metabase/dayjs";
import * as Urls from "metabase/urls";
@@ -381,6 +381,24 @@ describe("nav > containers > MainNavbar", () => {
).not.toBeInTheDocument();
});
+ it("should move focus through the new collection modal with Tab (#83338)", async () => {
+ await setup();
+
+ await userEvent.click(
+ screen.getByRole("button", { name: "Create a new collection" }),
+ );
+
+ const modal = await screen.findByRole("dialog", {
+ name: "New collection",
+ });
+ await waitFor(() => {
+ expect(within(modal).getByLabelText("Name")).toHaveFocus();
+ });
+
+ await userEvent.tab();
+ expect(within(modal).getByLabelText("Description")).toHaveFocus();
+ });
+
it("should toggle active collection on click", async () => {
const { regularCollectionElements } = await setupCollectionPage({
pathname: Urls.collection(TEST_COLLECTION),