mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
fix(skill): use Dialog initialFocus to focus input on modal open
Expose initialFocus prop on Modal component (passthrough to Headless UI Dialog) so the create blank skill modal reliably focuses the name input when opened, replacing the ineffective autoFocus attribute.
This commit is contained in:
@ -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<HTMLElement | null>
|
||||
}
|
||||
|
||||
export default function Modal({
|
||||
@ -35,10 +36,11 @@ export default function Modal({
|
||||
highPriority = false,
|
||||
overlayOpacity = false,
|
||||
clickOutsideNotClose = false,
|
||||
initialFocus,
|
||||
}: IModal) {
|
||||
return (
|
||||
<Transition appear show={isShow} as={Fragment}>
|
||||
<Dialog as="div" className={cn('relative', highPriority ? 'z-[1100]' : 'z-[60]', wrapperClassName)} onClose={clickOutsideNotClose ? noop : onClose}>
|
||||
<Dialog as="div" className={cn('relative', highPriority ? 'z-[1100]' : 'z-[60]', wrapperClassName)} onClose={clickOutsideNotClose ? noop : onClose} initialFocus={initialFocus}>
|
||||
<TransitionChild>
|
||||
<div className={cn('fixed inset-0', overlayOpacity ? 'bg-workflow-canvas-canvas-overlay' : 'bg-background-overlay', 'duration-300 ease-in data-[closed]:opacity-0', 'data-[enter]:opacity-100', 'data-[leave]:opacity-0')} />
|
||||
</TransitionChild>
|
||||
|
||||
Reference in New Issue
Block a user