fix(ui): avoid default modal action focus

This commit is contained in:
NimBold
2026-07-27 19:37:47 +03:30
parent eb73dde911
commit edc76a7fab
3 changed files with 8 additions and 2 deletions
+3 -1
View File
@@ -66,8 +66,10 @@ export const useModalFocus = (enabled = true) => {
const focusInitialElement = () => {
if (!isTopmostModal(surface)) return;
// Keep initial focus on the dialog itself. This avoids visually selecting
// an action when a modal opens from a pointer interaction; Tab still
// enters the first available control through the trap below.
const initialElement = surface.querySelector<HTMLElement>('[data-modal-autofocus="true"]')
|| getFocusableElements(surface)[0]
|| surface;
initialElement.focus({ preventScroll: true });
};