From 8febda5eee8a43191200a811d04261925700cb28 Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Mon, 17 Oct 2022 08:52:26 +0400 Subject: [PATCH] move InputErrorsTooltip to design-system --- .../sidebar-left/panels/pages/settings.tsx | 36 ++++--------------- .../design-system/src/components/tooltip.tsx | 28 +++++++++++++++ packages/design-system/src/index.ts | 2 +- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx b/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx index 08ac6ba4d9..fa855bb586 100644 --- a/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx +++ b/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx @@ -8,13 +8,13 @@ import { styled, Flex, toast, - Tooltip, + InputErrorsTooltip, } from "@webstudio-is/design-system"; import { useFetcher, type FetcherWithComponents } from "@remix-run/react"; import { ChevronDoubleLeftIcon } from "@webstudio-is/icons"; import type { ZodError } from "zod"; import { BaseHeader } from "../../lib/header"; -import React, { useEffect, useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { type Page } from "@webstudio-is/project"; const Group = styled(Flex, { @@ -27,30 +27,6 @@ export type CreatePageData = | { ok: true; page: Page } | { errors: string | ZodError["formErrors"] }; -const ErrorsTooltip = ({ - errors, - children, -}: { - errors: string[] | undefined; - children: React.ComponentProps["children"]; -}) => { - const content = errors?.map((error, i) => ( - - {i > 0 &&
} - {error} -
- )); - return ( - // We intentionally always pass non empty content to avoid optimization inside Tooltip - // where it renders {children} directly if content is empty. - // If this optimization accur, the will remount which will cause focus loss - // and current value loss. - - {children} - - ); -}; - export const NewPageSettings = ({ onClose, onSuccess, @@ -120,7 +96,7 @@ export const NewPageSettings = ({ - + rest); }} /> - + - + rest); }} /> - +