From 5edf89efadcc5a46d218c33a04385838b4b45b04 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Thu, 7 Nov 2024 16:47:29 -0600 Subject: [PATCH] Fix radix warnings on side modal (#2536) fix radix warnings on side modal --- app/ui/lib/SideModal.stories.tsx | 6 ++- app/ui/lib/SideModal.tsx | 80 ++++++++++++-------------------- 2 files changed, 34 insertions(+), 52 deletions(-) diff --git a/app/ui/lib/SideModal.stories.tsx b/app/ui/lib/SideModal.stories.tsx index db68546b87..51e2dbb0c4 100644 --- a/app/ui/lib/SideModal.stories.tsx +++ b/app/ui/lib/SideModal.stories.tsx @@ -17,7 +17,11 @@ export function Default() { return ( <> - setIsOpen(false)}> + setIsOpen(false)} + > Section content diff --git a/app/ui/lib/SideModal.tsx b/app/ui/lib/SideModal.tsx index 62d478c5e7..5bf63c8984 100644 --- a/app/ui/lib/SideModal.tsx +++ b/app/ui/lib/SideModal.tsx @@ -30,7 +30,7 @@ export function usePopoverZIndex() { } export type SideModalProps = { - title?: string + title: string subtitle?: ReactNode onDismiss: () => void isOpen: boolean @@ -53,7 +53,6 @@ export function SideModal({ animate = true, errors, }: SideModalProps) { - const titleId = 'side-modal-title' const AnimatedDialogContent = animated(Dialog.Content) const config = { tension: 650, mass: 0.125 } @@ -81,40 +80,39 @@ export function SideModal({ `translate3d(${value}%, 0px, 0px)`), }} + // shuts off a warning from radix about dialog content needing a description + aria-describedby={undefined} > - {title && ( - - <> - - - {errors && errors.length > 0 && ( -
- -
{errors.length} issues:
-
    - {errors.map((error, idx) => ( -
  • {error}
  • - ))} -
- - ) - } - title={errors.length > 1 ? 'Errors' : 'Error'} - /> -
- )} - +
+ + {title} + {subtitle} +
+ {errors && errors.length > 0 && ( +
+ +
{errors.length} issues:
+
    + {errors.map((error, idx) => ( +
  • {error}
  • + ))} +
+ + ) + } + title={errors.length > 1 ? 'Errors' : 'Error'} + /> +
)} {children}
@@ -128,26 +126,6 @@ export function SideModal({ export const ResourceLabel = classed.h3`mt-2 flex items-center gap-1.5 text-sans-md text-accent` -SideModal.Title = ({ - title, - id, - subtitle, -}: { - title: string - id?: string - subtitle?: ReactNode -}) => ( -
-

- {title} -

- {subtitle} -
-) - // separate component because otherwise eslint thinks it's not a component and // gets mad about the use of hooks function SideModalBody({ children }: { children?: ReactNode }) {