Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Autofocus form modal input field when possible in web app (#2413)

Leendert de Borst85a218ba1ef1
diff --git a/apps/web/src/components/shared/FormModal.tsx b/apps/web/src/components/shared/FormModal.tsx
index 0b21b3c80..fd3900b5a 100644
--- a/apps/web/src/components/shared/FormModal.tsx
+++ b/apps/web/src/components/shared/FormModal.tsx
@@ -49,8 +49,9 @@ const FormModal: React.FC<FormModalProps> = ({
const { t } = useTranslation();
const panelRef = useRef<HTMLDivElement>(null);
+ // Focus the panel for keyboard handling, unless a field inside it already took focus via autoFocus.
useEffect(() => {
- if (isOpen) {
+ if (isOpen && !panelRef.current?.contains(document.activeElement)) {
panelRef.current?.focus();
}
}, [isOpen]);