Skip to content

Commit 2b0c3f1

Browse files
Remove footer when side modal is read-only (#2621)
* Remove sidemodal footer when read-only * Update test to use X to close modal * move close button back into SideModal --------- Co-authored-by: David Crespo <[email protected]>
1 parent c1fbf63 commit 2b0c3f1

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

app/components/form/SideModalForm.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
* Copyright Oxide Computer Company
77
*/
8+
89
import { useEffect, useId, useState, type ReactNode } from 'react'
910
import type { FieldValues, UseFormReturn } from 'react-hook-form'
1011
import { NavigationType, useNavigationType } from 'react-router-dom'
@@ -127,11 +128,11 @@ export function SideModalForm<TFieldValues extends FieldValues>({
127128
{children}
128129
</form>
129130
</SideModal.Body>
130-
<SideModal.Footer error={!!submitError}>
131-
<Button variant="ghost" size="sm" onClick={onDismiss}>
132-
Cancel
133-
</Button>
134-
{onSubmit && (
131+
{onSubmit && (
132+
<SideModal.Footer error={!!submitError}>
133+
<Button variant="ghost" size="sm" onClick={onDismiss}>
134+
Cancel
135+
</Button>
135136
<Button
136137
type="submit"
137138
size="sm"
@@ -142,8 +143,8 @@ export function SideModalForm<TFieldValues extends FieldValues>({
142143
>
143144
{label}
144145
</Button>
145-
)}
146-
</SideModal.Footer>
146+
</SideModal.Footer>
147+
)}
147148

148149
{showNavGuard && (
149150
<Modal

app/ui/lib/SideModal.tsx

+8-10
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ export function SideModal({
115115
</div>
116116
)}
117117
{children}
118+
119+
{/* Close button is here at the end so we aren't automatically focusing on it when the side modal is opened. Positioned in the safe area at the top */}
120+
<Dialog.Close
121+
className="absolute right-[var(--content-gutter)] top-10 -m-2 flex rounded p-2 hover:bg-hover"
122+
aria-label="Close"
123+
>
124+
<Close12Icon className="text-default" />
125+
</Dialog.Close>
118126
</AnimatedDialogContent>
119127
</Dialog.Portal>
120128
</Dialog.Root>
@@ -161,15 +169,5 @@ SideModal.Footer = ({ children, error }: { children: ReactNode; error?: boolean
161169
</div>
162170
)}
163171
{children}
164-
{/*
165-
Close button is here at the end so we aren't automatically focusing on it
166-
when the side modal is opened. Positioned in the safe area at the top
167-
*/}
168-
<Dialog.Close
169-
className="absolute right-[var(--content-gutter)] top-10 -m-2 flex rounded p-2 hover:bg-hover"
170-
aria-label="Close"
171-
>
172-
<Close12Icon className="text-default" />
173-
</Dialog.Close>
174172
</footer>
175173
)

test/e2e/silos.e2e.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ test('Identity providers', async ({ page }) => {
200200
'groups'
201201
)
202202

203-
await page.getByRole('button', { name: 'Cancel' }).click()
203+
await page.getByRole('button', { name: 'Close' }).click()
204204

205205
await expect(dialog).toBeHidden()
206206

@@ -320,7 +320,7 @@ test('Silo IP pools link pool', async ({ page }) => {
320320
await expect(modal).toBeVisible()
321321

322322
// close modal works
323-
await page.getByRole('button', { name: 'Cancel' }).click()
323+
await page.getByRole('button', { name: 'Close' }).click()
324324
await expect(modal).toBeHidden()
325325

326326
// reopen

0 commit comments

Comments
 (0)