Browse Source

wip(desktop): progress

Adam 2 months ago
parent
commit
acd91bddf7
2 changed files with 13 additions and 0 deletions
  1. 5 0
      packages/desktop/src/pages/session.tsx
  2. 8 0
      packages/ui/src/components/dialog.tsx

+ 5 - 0
packages/desktop/src/pages/session.tsx

@@ -185,6 +185,11 @@ export default function Page() {
       return
     }
 
+    // Don't interfere with dialogs
+    if (dialog.stack.length > 0) {
+      return
+    }
+
     const focused = document.activeElement === inputRef
     if (focused) {
       if (event.key === "Escape") {

+ 8 - 0
packages/ui/src/components/dialog.tsx

@@ -20,6 +20,14 @@ export function Dialog(props: DialogProps) {
             ...(props.classList ?? {}),
             [props.class ?? ""]: !!props.class,
           }}
+          onOpenAutoFocus={(e) => {
+            const target = e.currentTarget as HTMLElement | null
+            const autofocusEl = target?.querySelector("[autofocus]") as HTMLElement | null
+            if (autofocusEl) {
+              e.preventDefault()
+              autofocusEl.focus()
+            }
+          }}
         >
           <Show when={props.title || props.action}>
             <div data-slot="dialog-header">