From c34810b161273e6fac3650b2564494ee9235cced Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Sat, 6 Jan 2024 12:22:30 -0300 Subject: [PATCH] Fixed Confirmation Modal ref --- .../src/components/floatComponent/index.tsx | 2 +- .../src/components/intComponent/index.tsx | 4 ++-- .../src/modals/ConfirmationModal/index.tsx | 23 ++++++++++++------- src/frontend/src/modals/baseModal/index.tsx | 1 + src/frontend/src/modals/shareModal/index.tsx | 3 --- src/frontend/src/pages/AdminPage/index.tsx | 18 ++++++--------- .../components/nodeToolbarComponent/index.tsx | 4 ---- src/frontend/src/types/components/index.ts | 9 ++++---- 8 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/frontend/src/components/floatComponent/index.tsx b/src/frontend/src/components/floatComponent/index.tsx index 9716da83c..a4ebf1ae9 100644 --- a/src/frontend/src/components/floatComponent/index.tsx +++ b/src/frontend/src/components/floatComponent/index.tsx @@ -48,7 +48,7 @@ export default function FloatComponent({ onChange(event.target.value); }} onKeyDown={(e) => { - handleKeyDown(e, value, "0"); + handleKeyDown(e, value, ""); }} /> diff --git a/src/frontend/src/components/intComponent/index.tsx b/src/frontend/src/components/intComponent/index.tsx index d9d3504ae..25ac37369 100644 --- a/src/frontend/src/components/intComponent/index.tsx +++ b/src/frontend/src/components/intComponent/index.tsx @@ -25,11 +25,11 @@ export default function IntComponent({ id={id} onKeyDown={(event) => { handleOnlyIntegerInput(event); - handleKeyDown(event, value, "0"); + handleKeyDown(event, value, ""); }} type="number" step="1" - min={min} + min={0} onInput={(event: React.ChangeEvent) => { if (Number(event.target.value) < min) { event.target.value = min.toString(); diff --git a/src/frontend/src/modals/ConfirmationModal/index.tsx b/src/frontend/src/modals/ConfirmationModal/index.tsx index 11d711912..e5b8c629f 100644 --- a/src/frontend/src/modals/ConfirmationModal/index.tsx +++ b/src/frontend/src/modals/ConfirmationModal/index.tsx @@ -1,29 +1,29 @@ import React, { useEffect, useState } from "react"; import ShadTooltip from "../../components/ShadTooltipComponent"; import { Button } from "../../components/ui/button"; -import { ConfirmationModalType, ContentProps } from "../../types/components"; +import { ConfirmationModalType, ContentProps, TriggerProps } from "../../types/components"; import { nodeIconsLucide } from "../../utils/styleUtils"; import BaseModal from "../baseModal"; const Content: React.FC = ({ children }) => { return
{children}
; }; -const Trigger: React.FC = ({ +const Trigger: React.FC = ({ children, - tolltipContent, + tooltipContent, side, + asChild, }) => { - return tolltipContent ? ( - + return asChild ? children : (tooltipContent ? ( +
{children}
) : (
{children}
- ); + )); }; function ConfirmationModal({ title, - asChild, titleHeader, modalContentTitle, cancelText, @@ -49,6 +49,7 @@ function ConfirmationModal({ useEffect(() => { if (onClose) onClose!(modalOpen); }, [modalOpen]); + const triggerChild = React.Children.toArray(children).find( (child) => (child as React.ReactElement).type === Trigger ); @@ -58,7 +59,13 @@ function ConfirmationModal({ return ( - {triggerChild} + <> + {triggerChild && ( + + {triggerChild} + + )} + {title} = ({ children, asChild, disable }) => {