Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions app/components/form/SideModalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* Copyright Oxide Computer Company
*/

import { useEffect, useId, useState, type ReactNode } from 'react'
import type { FieldValues, UseFormReturn } from 'react-hook-form'
import { NavigationType, useNavigationType } from 'react-router-dom'
Expand Down Expand Up @@ -127,11 +128,11 @@ export function SideModalForm<TFieldValues extends FieldValues>({
{children}
</form>
</SideModal.Body>
<SideModal.Footer error={!!submitError}>
<Button variant="ghost" size="sm" onClick={onDismiss}>
Cancel
</Button>
{onSubmit && (
{onSubmit && (
<SideModal.Footer error={!!submitError}>
<Button variant="ghost" size="sm" onClick={onDismiss}>
Cancel
</Button>
<Button
type="submit"
size="sm"
Expand All @@ -142,8 +143,8 @@ export function SideModalForm<TFieldValues extends FieldValues>({
>
{label}
</Button>
)}
</SideModal.Footer>
</SideModal.Footer>
)}

{showNavGuard && (
<Modal
Expand Down
18 changes: 8 additions & 10 deletions app/ui/lib/SideModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ export function SideModal({
</div>
)}
{children}

{/* 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 */}
<Dialog.Close
className="absolute right-[var(--content-gutter)] top-10 -m-2 flex rounded p-2 hover:bg-hover"
aria-label="Close"
>
<Close12Icon className="text-default" />
</Dialog.Close>
</AnimatedDialogContent>
</Dialog.Portal>
</Dialog.Root>
Expand Down Expand Up @@ -161,15 +169,5 @@ SideModal.Footer = ({ children, error }: { children: ReactNode; error?: boolean
</div>
)}
{children}
{/*
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
*/}
<Dialog.Close
className="absolute right-[var(--content-gutter)] top-10 -m-2 flex rounded p-2 hover:bg-hover"
aria-label="Close"
>
<Close12Icon className="text-default" />
</Dialog.Close>
</footer>
)
4 changes: 2 additions & 2 deletions test/e2e/silos.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ test('Identity providers', async ({ page }) => {
'groups'
)

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

await expect(dialog).toBeHidden()

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

// close modal works
await page.getByRole('button', { name: 'Cancel' }).click()
await page.getByRole('button', { name: 'Close' }).click()
await expect(modal).toBeHidden()

// reopen
Expand Down
Loading