File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -217,6 +217,7 @@ interface BaseModalProps {
217217 type ?: "modal" | "dialog" | "full-screen" ;
218218 onSubmit ?: ( ) => void ;
219219 onEscapeKeyDown ?: ( e : KeyboardEvent ) => void ;
220+ onOpenAutoFocus ?: ( e : Event ) => void ;
220221 closeButtonClassName ?: string ;
221222 dialogContentWithouFixed ?: boolean ;
222223}
@@ -230,6 +231,7 @@ function BaseModal({
230231 type = "dialog" ,
231232 onSubmit,
232233 onEscapeKeyDown,
234+ onOpenAutoFocus,
233235 closeButtonClassName,
234236 dialogContentWithouFixed = false ,
235237} : BaseModalProps ) {
@@ -290,6 +292,7 @@ function BaseModal({
290292 < DialogContentWithouFixed
291293 onClick = { ( e ) => e . stopPropagation ( ) }
292294 onEscapeKeyDown = { onEscapeKeyDown }
295+ onOpenAutoFocus = { onOpenAutoFocus }
293296 className = { contentClasses }
294297 closeButtonClassName = { closeButtonClassName }
295298 >
@@ -311,6 +314,7 @@ function BaseModal({
311314 < DialogContent
312315 onClick = { ( e ) => e . stopPropagation ( ) }
313316 onEscapeKeyDown = { onEscapeKeyDown }
317+ onOpenAutoFocus = { onOpenAutoFocus }
314318 className = { contentClasses }
315319 closeButtonClassName = { closeButtonClassName }
316320 >
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ function ConfirmationModal({
4141 index,
4242 onConfirm,
4343 open,
44+ onOpenAutoFocus,
4445 onClose,
4546 onCancel,
4647 ...props
@@ -78,7 +79,12 @@ function ConfirmationModal({
7879 } ;
7980
8081 return (
81- < BaseModal { ...props } open = { open } setOpen = { setModalOpen } >
82+ < BaseModal
83+ { ...props }
84+ open = { open }
85+ setOpen = { setModalOpen }
86+ onOpenAutoFocus = { onOpenAutoFocus }
87+ >
8288 < BaseModal . Trigger > { triggerChild } </ BaseModal . Trigger >
8389 < BaseModal . Header description = { titleHeader ?? null } >
8490 < span className = "pr-2" > { title } </ span >
Original file line number Diff line number Diff line change @@ -90,9 +90,25 @@ export default function FlowLogsModal({
9090 }
9191 } , [ ] ) ;
9292
93+ const handleOpenAutoFocus = useCallback ( ( e : Event ) => {
94+ const viewport = document . querySelector (
95+ ".ag-body-viewport" ,
96+ ) as HTMLElement | null ;
97+ if ( viewport ) {
98+ e . preventDefault ( ) ;
99+ viewport . focus ( ) ;
100+ }
101+ // If viewport doesn't exist (empty table), let default focus behavior happen
102+ } , [ ] ) ;
103+
93104 return (
94105 < >
95- < BaseModal open = { open } setOpen = { setOpen } size = "x-large" >
106+ < BaseModal
107+ open = { open }
108+ setOpen = { setOpen }
109+ size = "x-large"
110+ onOpenAutoFocus = { handleOpenAutoFocus }
111+ >
96112 < BaseModal . Trigger asChild > { children } </ BaseModal . Trigger >
97113 < BaseModal . Header description = "Inspect component executions." >
98114 < div className = "flex w-full justify-between" >
Original file line number Diff line number Diff line change 11import { truncate } from "lodash" ;
2- import { useState } from "react" ;
2+ import { useCallback , useState } from "react" ;
33import ForwardedIconComponent from "@/components/common/genericIconComponent" ;
44import Loading from "@/components/ui/loading" ;
55import ConfirmationModal from "../confirmationModal" ;
@@ -20,6 +20,14 @@ export function SaveChangesModal({
2020 autoSave : boolean ;
2121} ) : JSX . Element {
2222 const [ saving , setSaving ] = useState ( false ) ;
23+
24+ const handleOpenAutoFocus = useCallback ( ( e : Event ) => {
25+ e . preventDefault ( ) ;
26+ (
27+ document . querySelector ( '[data-testid="replace-button"]' ) as HTMLElement
28+ ) ?. focus ( ) ;
29+ } , [ ] ) ;
30+
2331 return (
2432 < ConfirmationModal
2533 open = { true }
@@ -42,6 +50,7 @@ export function SaveChangesModal({
4250 onCancel = { onProceed }
4351 loading = { autoSave ? true : saving }
4452 size = "x-small"
53+ onOpenAutoFocus = { handleOpenAutoFocus }
4554 >
4655 < ConfirmationModal . Content >
4756 { autoSave ? (
Original file line number Diff line number Diff line change @@ -407,6 +407,7 @@ export type ConfirmationModalType = {
407407 | "small-h-full"
408408 | "medium-h-full" ;
409409 onEscapeKeyDown ?: ( e : KeyboardEvent ) => void ;
410+ onOpenAutoFocus ?: ( e : Event ) => void ;
410411} ;
411412
412413export type UserManagementType = {
Original file line number Diff line number Diff line change 8989 await expect (
9090 page . getByText ( "timestamp" , { exact : true } ) . last ( ) ,
9191 ) . toBeAttached ( ) ;
92- await expect ( page . getByText ( "text" , { exact : true } ) . last ( ) ) . toBeAttached ( ) ;
92+ await expect (
93+ page . getByText ( "files" , { exact : true } ) . last ( ) ,
94+ ) . toBeAttached ( ) ;
9395 await expect (
9496 page . getByText ( "sender" , { exact : true } ) . last ( ) ,
9597 ) . toBeAttached ( ) ;
You can’t perform that action at this time.
0 commit comments