diff --git a/web/app/components/base/modal/index.tsx b/web/app/components/base/modal/index.tsx index 192fb7b70a..0e15613a7e 100644 --- a/web/app/components/base/modal/index.tsx +++ b/web/app/components/base/modal/index.tsx @@ -19,6 +19,7 @@ type IModal = { highPriority?: boolean // For modals that need to appear above dropdowns overlayOpacity?: boolean // For semi-transparent overlay instead of default clickOutsideNotClose?: boolean // Prevent closing when clicking outside modal + initialFocus?: React.RefObject } export default function Modal({ @@ -35,10 +36,11 @@ export default function Modal({ highPriority = false, overlayOpacity = false, clickOutsideNotClose = false, + initialFocus, }: IModal) { return ( - +
diff --git a/web/app/components/workflow/skill/start-tab/create-blank-skill-modal.tsx b/web/app/components/workflow/skill/start-tab/create-blank-skill-modal.tsx index fe5e6c2556..499008e31b 100644 --- a/web/app/components/workflow/skill/start-tab/create-blank-skill-modal.tsx +++ b/web/app/components/workflow/skill/start-tab/create-blank-skill-modal.tsx @@ -46,6 +46,8 @@ const CreateBlankSkillModal = ({ isOpen, onClose }: CreateBlankSkillModalProps) const { data: existingNames } = useExistingSkillNames() + const inputRef = useRef(null) + const trimmedName = skillName.trim() const isDuplicate = !!trimmedName && (existingNames?.has(trimmedName) ?? false) const canCreate = !!trimmedName && !isDuplicate && !isCreating @@ -116,18 +118,19 @@ const CreateBlankSkillModal = ({ isOpen, onClose }: CreateBlankSkillModalProps) title={t('skill.startTab.createModal.title', { ns: 'workflow' })} closable={!isCreating} clickOutsideNotClose={isCreating} + initialFocus={inputRef} >
setSkillName(e.target.value)} placeholder={t('skill.startTab.createModal.namePlaceholder', { ns: 'workflow' }) || ''} destructive={isDuplicate} disabled={isCreating} - autoFocus onKeyDown={(e) => { if (e.key === 'Enter' && canCreate) handleCreate()