Skip to content
Open
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
4 changes: 4 additions & 0 deletions src/frontend/src/modals/baseModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ interface BaseModalProps {
type?: "modal" | "dialog" | "full-screen";
onSubmit?: () => void;
onEscapeKeyDown?: (e: KeyboardEvent) => void;
onOpenAutoFocus?: (e: Event) => void;
closeButtonClassName?: string;
dialogContentWithouFixed?: boolean;
}
Expand All @@ -230,6 +231,7 @@ function BaseModal({
type = "dialog",
onSubmit,
onEscapeKeyDown,
onOpenAutoFocus,
closeButtonClassName,
dialogContentWithouFixed = false,
}: BaseModalProps) {
Expand Down Expand Up @@ -290,6 +292,7 @@ function BaseModal({
<DialogContentWithouFixed
onClick={(e) => e.stopPropagation()}
onEscapeKeyDown={onEscapeKeyDown}
onOpenAutoFocus={onOpenAutoFocus}
className={contentClasses}
closeButtonClassName={closeButtonClassName}
>
Expand All @@ -311,6 +314,7 @@ function BaseModal({
<DialogContent
onClick={(e) => e.stopPropagation()}
onEscapeKeyDown={onEscapeKeyDown}
onOpenAutoFocus={onOpenAutoFocus}
className={contentClasses}
closeButtonClassName={closeButtonClassName}
>
Expand Down
8 changes: 7 additions & 1 deletion src/frontend/src/modals/confirmationModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function ConfirmationModal({
index,
onConfirm,
open,
onOpenAutoFocus,
onClose,
onCancel,
...props
Expand Down Expand Up @@ -78,7 +79,12 @@ function ConfirmationModal({
};

return (
<BaseModal {...props} open={open} setOpen={setModalOpen}>
<BaseModal
{...props}
open={open}
setOpen={setModalOpen}
onOpenAutoFocus={onOpenAutoFocus}
>
<BaseModal.Trigger>{triggerChild}</BaseModal.Trigger>
<BaseModal.Header description={titleHeader ?? null}>
<span className="pr-2">{title}</span>
Expand Down
12 changes: 11 additions & 1 deletion src/frontend/src/modals/flowLogsModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,19 @@ export default function FlowLogsModal({
}
}, []);

const handleOpenAutoFocus = useCallback((e: Event) => {
e.preventDefault();
(document.querySelector(".ag-body-viewport") as HTMLElement)?.focus();
}, []);

return (
<>
<BaseModal open={open} setOpen={setOpen} size="x-large">
<BaseModal
open={open}
setOpen={setOpen}
size="x-large"
onOpenAutoFocus={handleOpenAutoFocus}
>
<BaseModal.Trigger asChild>{children}</BaseModal.Trigger>
<BaseModal.Header description="Inspect component executions.">
<div className="flex w-full justify-between">
Expand Down
11 changes: 10 additions & 1 deletion src/frontend/src/modals/saveChangesModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { truncate } from "lodash";
import { useState } from "react";
import { useCallback, useState } from "react";
import ForwardedIconComponent from "@/components/common/genericIconComponent";
import Loading from "@/components/ui/loading";
import ConfirmationModal from "../confirmationModal";
Expand All @@ -20,6 +20,14 @@ export function SaveChangesModal({
autoSave: boolean;
}): JSX.Element {
const [saving, setSaving] = useState(false);

const handleOpenAutoFocus = useCallback((e: Event) => {
e.preventDefault();
(
document.querySelector('[data-testid="replace-button"]') as HTMLElement
)?.focus();
}, []);

return (
<ConfirmationModal
open={true}
Expand All @@ -42,6 +50,7 @@ export function SaveChangesModal({
onCancel={onProceed}
loading={autoSave ? true : saving}
size="x-small"
onOpenAutoFocus={handleOpenAutoFocus}
>
<ConfirmationModal.Content>
{autoSave ? (
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/types/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ export type ConfirmationModalType = {
| "small-h-full"
| "medium-h-full";
onEscapeKeyDown?: (e: KeyboardEvent) => void;
onOpenAutoFocus?: (e: Event) => void;
};

export type UserManagementType = {
Expand Down
Loading