Skip to content

Commit 5edf89e

Browse files
authored
Fix radix warnings on side modal (#2536)
fix radix warnings on side modal
1 parent dcddc81 commit 5edf89e

File tree

2 files changed

+34
-52
lines changed

2 files changed

+34
-52
lines changed

app/ui/lib/SideModal.stories.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export function Default() {
1717
return (
1818
<>
1919
<Button onClick={() => setIsOpen(true)}>Open menu</Button>
20-
<SideModal isOpen={isOpen} onDismiss={() => setIsOpen(false)}>
20+
<SideModal
21+
title="Create something"
22+
isOpen={isOpen}
23+
onDismiss={() => setIsOpen(false)}
24+
>
2125
<SideModal.Body>
2226
<SideModal.Section>Section content</SideModal.Section>
2327
<SideModal.Section>

app/ui/lib/SideModal.tsx

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function usePopoverZIndex() {
3030
}
3131

3232
export type SideModalProps = {
33-
title?: string
33+
title: string
3434
subtitle?: ReactNode
3535
onDismiss: () => void
3636
isOpen: boolean
@@ -53,7 +53,6 @@ export function SideModal({
5353
animate = true,
5454
errors,
5555
}: SideModalProps) {
56-
const titleId = 'side-modal-title'
5756
const AnimatedDialogContent = animated(Dialog.Content)
5857

5958
const config = { tension: 650, mass: 0.125 }
@@ -81,40 +80,39 @@ export function SideModal({
8180
<DialogOverlay />
8281
<AnimatedDialogContent
8382
className="DialogContent ox-side-modal pointer-events-auto fixed bottom-0 right-0 top-0 z-sideModal m-0 flex w-[32rem] flex-col justify-between border-l p-0 bg-raise border-secondary elevation-2"
84-
aria-labelledby={titleId}
8583
style={{
8684
transform: x.to((value) => `translate3d(${value}%, 0px, 0px)`),
8785
}}
86+
// shuts off a warning from radix about dialog content needing a description
87+
aria-describedby={undefined}
8888
>
89-
{title && (
90-
<Dialog.Title asChild>
91-
<>
92-
<SideModal.Title id={titleId} title={title} subtitle={subtitle} />
93-
94-
{errors && errors.length > 0 && (
95-
<div className="mb-6">
96-
<Message
97-
variant="error"
98-
content={
99-
errors.length === 1 ? (
100-
errors[0]
101-
) : (
102-
<>
103-
<div>{errors.length} issues:</div>
104-
<ul className="ml-4 list-disc">
105-
{errors.map((error, idx) => (
106-
<li key={idx}>{error}</li>
107-
))}
108-
</ul>
109-
</>
110-
)
111-
}
112-
title={errors.length > 1 ? 'Errors' : 'Error'}
113-
/>
114-
</div>
115-
)}
116-
</>
89+
<div className="items-top mb-4 mt-8">
90+
<Dialog.Title className="flex w-full items-center justify-between break-words pr-8 text-sans-2xl">
91+
{title}
11792
</Dialog.Title>
93+
{subtitle}
94+
</div>
95+
{errors && errors.length > 0 && (
96+
<div className="mb-6">
97+
<Message
98+
variant="error"
99+
content={
100+
errors.length === 1 ? (
101+
errors[0]
102+
) : (
103+
<>
104+
<div>{errors.length} issues:</div>
105+
<ul className="ml-4 list-disc">
106+
{errors.map((error, idx) => (
107+
<li key={idx}>{error}</li>
108+
))}
109+
</ul>
110+
</>
111+
)
112+
}
113+
title={errors.length > 1 ? 'Errors' : 'Error'}
114+
/>
115+
</div>
118116
)}
119117
{children}
120118
</AnimatedDialogContent>
@@ -128,26 +126,6 @@ export function SideModal({
128126

129127
export const ResourceLabel = classed.h3`mt-2 flex items-center gap-1.5 text-sans-md text-accent`
130128

131-
SideModal.Title = ({
132-
title,
133-
id,
134-
subtitle,
135-
}: {
136-
title: string
137-
id?: string
138-
subtitle?: ReactNode
139-
}) => (
140-
<div className="items-top mb-4 mt-8">
141-
<h2
142-
className="flex w-full items-center justify-between break-words pr-8 text-sans-2xl"
143-
id={id}
144-
>
145-
{title}
146-
</h2>
147-
{subtitle}
148-
</div>
149-
)
150-
151129
// separate component because otherwise eslint thinks it's not a component and
152130
// gets mad about the use of hooks
153131
function SideModalBody({ children }: { children?: ReactNode }) {

0 commit comments

Comments
 (0)