Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Focus: closing search, a menu or a dialog no longer leaves a ring on something you only clicked

Eric Brownrout38b83e1e0d28
diff --git a/app/e2e/agendaLoading.spec.ts b/app/e2e/agendaLoading.spec.ts
index b16cb5ae..24434799 100644
--- a/app/e2e/agendaLoading.spec.ts
+++ b/app/e2e/agendaLoading.spec.ts
@@ -152,6 +152,9 @@ test('the compact calendar keeps its original type and geometry with a bright to
await expect(page.locator('.agenda-day > span')).toHaveCSS('font-weight', '400')
const other = week.locator('button:not([aria-current=date])').first()
await other.focus()
+ await page.keyboard.press('Tab')
+ await page.keyboard.press('Shift+Tab')
+ await expect(other).toBeFocused()
await page.keyboard.press('Space')
await expect(other).toHaveAttribute('aria-pressed', 'true')
await expect(today).toHaveAttribute('aria-pressed', 'false')
diff --git a/app/e2e/calendarLink.spec.ts b/app/e2e/calendarLink.spec.ts
index be0902b5..236e6044 100644
--- a/app/e2e/calendarLink.spec.ts
+++ b/app/e2e/calendarLink.spec.ts
@@ -30,6 +30,7 @@ test('@everywhere on win32: the agenda sends you to Settings, a calendar link co
const form = page.getByTestId('calendar-link-form')
await expect(form).toBeVisible()
await expect(page.getByTestId('calendar-link-add')).toContainText('Add a calendar by link')
+ await expect(form.getByTestId('calendar-link-input')).toBeFocused()
await expect(page.getByText("Calendars from the Mac's Calendar app appear above automatically.", { exact: true })).toHaveCount(0)
await expect(form.getByTestId('calendar-link-open')).toHaveAttribute('href', /calendar\.google\.com/)
await form.getByTestId('calendar-link-provider-outlook').click()
diff --git a/app/e2e/commands.spec.ts b/app/e2e/commands.spec.ts
index 179a8770..516b475e 100644
--- a/app/e2e/commands.spec.ts
+++ b/app/e2e/commands.spec.ts
@@ -12,6 +12,51 @@ async function launch(env: Record<string, string> = {}) {
return { app, page }
}
+test('@everywhere search returns focus with the same ring the opener had', async () => {
+ const { app, page } = await launch({ YOGURT_BACKGROUND: process.env.YOGURT_BACKGROUND ?? '1' })
+ try {
+ const opener = page.getByTestId('nav-home'), search = page.getByTestId('search')
+ await opener.click()
+ for (const keyboard of [false, true]) {
+ if (keyboard) {
+ await page.keyboard.press('Tab')
+ await page.keyboard.press('Shift+Tab')
+ await expect(opener).toBeFocused()
+ await expect(opener).toHaveCSS('outline-style', 'solid')
+ }
+ await page.keyboard.press('ControlOrMeta+k')
+ await expect(page.getByTestId('search-input')).toBeFocused()
+ await page.keyboard.type('meet')
+ await page.keyboard.press('ArrowDown')
+ await page.keyboard.press('Escape')
+ await expect(search).toHaveCount(0)
+ await expect(opener).toBeFocused()
+ await expect(opener).toHaveCSS('outline-style', keyboard ? 'solid' : 'none')
+ }
+ await opener.click()
+ await page.keyboard.press('ControlOrMeta+k')
+ await page.getByTestId('search-input').fill('settings')
+ await expect(page.getByTestId('command-settings')).toHaveAttribute('aria-selected', 'true')
+ await page.keyboard.press('Enter')
+ await expect(page.getByTestId('settings')).toBeVisible()
+ await expect(search).toHaveCount(0)
+ if (await page.evaluate(() => window.yogurt.capabilities.calendarLink)) {
+ await expect(page.getByTestId('calendar-link-add')).toHaveAttribute('aria-expanded', 'true')
+ await expect(page.getByTestId('calendar-link-input')).not.toBeFocused()
+ }
+ await expect(opener).toBeFocused()
+ await expect(opener).toHaveCSS('outline-style', 'none')
+
+ // A shortcut from an unfocused page must not pick the first sidebar button.
+ await opener.evaluate(el => (el as HTMLElement).blur())
+ await page.keyboard.press('ControlOrMeta+k')
+ await expect(page.getByTestId('search-input')).toBeFocused()
+ await page.keyboard.press('Escape')
+ await expect(search).toHaveCount(0)
+ await expect.poll(() => page.evaluate(() => document.activeElement === document.body)).toBe(true)
+ } finally { await app.close() }
+})
+
test('a future date command opens Meetings on that agenda day and its week', async () => {
const { app, page } = await launch()
try {
@@ -518,6 +563,8 @@ test('typing keeps the palette frame steady and replaces meeting and command res
test('shortcut help opens from the palette and its footer, is searchable, and closes with Escape', async () => {
const { app, page } = await launch()
try {
+ const opener = page.getByTestId('nav-home')
+ await opener.click()
await page.keyboard.press('Meta+k')
await page.getByTestId('search-input').fill('shortcuts')
await expect(page.getByTestId('command-shortcuts')).toBeVisible()
@@ -530,6 +577,8 @@ test('shortcut help opens from the palette and its footer, is searchable, and cl
await expect(help).toContainText('⌘]')
await page.keyboard.press('Escape')
await expect(help).toHaveCount(0)
+ await expect(opener).toBeFocused()
+ await expect(opener).toHaveCSS('outline-style', 'none')
await page.keyboard.press('Meta+k')
await page.getByTestId('search-shortcuts').click()
await expect(help).toBeVisible()
diff --git a/app/e2e/menuMotion.spec.ts b/app/e2e/menuMotion.spec.ts
index 1789ab04..7d4c3e88 100644
--- a/app/e2e/menuMotion.spec.ts
+++ b/app/e2e/menuMotion.spec.ts
@@ -63,8 +63,14 @@ test('pointer menus share anchored entry in LTR and RTL; reduced motion keeps on
const left = menu.logical && (menu.end ? dir === 'rtl' : dir === 'ltr')
expect(actual.x).toBeCloseTo(left ? 0 : actual.width, 1)
await expect(page.getByTestId(menu.first)).toBeFocused()
+ if (menu.surface === 'note-menu') {
+ await page.keyboard.press('ArrowDown')
+ await expect(surface.locator(':focus')).not.toHaveCSS('background-color', 'rgba(0, 0, 0, 0)')
+ }
await page.keyboard.press('Escape')
await expect(surface).toHaveCount(0)
+ await expect(page.getByTestId(menu.trigger)).toBeFocused()
+ await expect(page.getByTestId(menu.trigger)).toHaveCSS('outline-style', 'none')
}
}
await page.emulateMedia({ reducedMotion: 'reduce' })
diff --git a/app/e2e/note-layout.spec.ts b/app/e2e/note-layout.spec.ts
index ddcc3445..992470dd 100644
--- a/app/e2e/note-layout.spec.ts
+++ b/app/e2e/note-layout.spec.ts
@@ -151,6 +151,7 @@ test('people added and removed by hand are saved, and the notes are written agai
await page.mouse.move(0, 0)
await expect(card.getByTestId('people-remove')).toHaveCSS('opacity', '0')
await card.getByTestId('people-remove').focus()
+ await expect(card.getByTestId('people-remove')).toHaveCSS('outline-style', 'none')
await expect(card.getByTestId('people-remove')).toHaveCSS('opacity', '1')
await expect(page.getByTestId('note-attendees-summary')).toHaveText('Maya')
expect((await page.evaluate((id) => window.yogurt.meetings.get(id), id))?.attendees).toEqual([{ name: 'Maya Chen', email: '[email protected]' }])
diff --git a/app/e2e/trash.spec.ts b/app/e2e/trash.spec.ts
index 4aab0831..69047814 100644
--- a/app/e2e/trash.spec.ts
+++ b/app/e2e/trash.spec.ts
@@ -111,10 +111,13 @@ test('meeting rows swap metadata for More without shifting content and share poi
await expect(page.getByTestId('meeting-row-folders')).toBeVisible()
await page.keyboard.press('Escape')
await expect(link).toBeFocused()
+ await expect(card).toHaveCSS('outline-style', 'solid')
await card.click({ button: 'right', position: { x: 40, y: 20 } })
await expect(menu.getByRole('menuitem')).toHaveText(['Select', 'Add to folder', 'Move to Trash'])
await page.keyboard.press('Escape')
await expect(link).toBeFocused()
+ await expect(link).toHaveCSS('outline-style', 'none')
+ await expect(card).toHaveCSS('outline-style', 'none')
await page.keyboard.press('Backspace')
await expect(page.getByTestId('past-note')).toHaveCount(4)
await page.keyboard.press('Delete')
@@ -182,9 +185,13 @@ test('the toast countdown pauses on hover and focus, then dismisses when time ru
await expect(trashRow.locator('.trash-actions')).toHaveCSS('opacity', '0')
await expect(trashRow.locator('.meeting-meta time')).toHaveText(/\d+:\d+/)
await expect(trashRow.locator('.meeting-meta')).toHaveCSS('opacity', '1')
- // Programmatic focus after a mouse click stays in pointer mode; only keyboard focus reveals actions.
+ // Quiet focus on the row keeps metadata in place. Focusing a hidden action must reveal it.
await trashRow.focus()
await expect(trashRow.locator('.trash-actions')).toHaveCSS('opacity', '0')
+ await trashRow.getByTestId('trash-restore').focus()
+ await expect(trashRow.locator('.trash-actions')).toHaveCSS('opacity', '1')
+ await expect(trashRow.getByTestId('trash-restore')).toHaveCSS('outline-style', 'none')
+ await trashRow.focus()
await page.keyboard.press('Tab')
await trashRow.focus()
await expect(trashRow.locator('.trash-actions')).toHaveCSS('opacity', '1')
diff --git a/app/src/main/index.ts b/app/src/main/index.ts
index 638130b7..eaab87a8 100644
--- a/app/src/main/index.ts
+++ b/app/src/main/index.ts
@@ -1053,7 +1053,7 @@ app.whenReady().then(() => {
})
ipcMain.handle('calendar:connect', async () => {
// a calendar link is pasted in Settings' calendars: the same form as the first run's
- if (calendarLinks && caps.calendarLink) { goTo('/settings'); return refreshCalendarStatus() }
+ if (calendarLinks && caps.calendarLink) { goTo('/settings/calendar'); return refreshCalendarStatus() }
const was = await refreshCalendarStatus()
if (was === 'notDetermined') return requestCalendarAccess()
if (was === 'denied') {
diff --git a/app/src/renderer/src/components/AnswerText.tsx b/app/src/renderer/src/components/AnswerText.tsx
index 26593a9f..987e9f76 100644
--- a/app/src/renderer/src/components/AnswerText.tsx
+++ b/app/src/renderer/src/components/AnswerText.tsx
@@ -1,3 +1,4 @@
+import { visibleFocus } from '../focusNavigation'
import { Fragment, useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import { Popover } from '@base-ui/react/popover'
import type { LibrarySource } from '../../../shared/types'
@@ -43,7 +44,7 @@ export function AnswerText({ md, live, sources, onSource }: {
}
}, [doc, open, triggerId])
const ctx: Ctx = { intent, live, at: { n: 0 }, id, sources, pinned, focus: (element) => {
- if (!element.matches(':focus-visible')) return
+ if (!element.matches(visibleFocus)) return
if (suppressed.current === element.id) { suppressed.current = null; return }
intent.focus(element)
}, blur: () => { suppressed.current = null },
diff --git a/app/src/renderer/src/components/CalendarSettings.tsx b/app/src/renderer/src/components/CalendarSettings.tsx
index f27000c5..eda3a7d3 100644
--- a/app/src/renderer/src/components/CalendarSettings.tsx
+++ b/app/src/renderer/src/components/CalendarSettings.tsx
@@ -7,22 +7,27 @@ import { t } from '../../../shared/i18n'
let expanded = false
-export function CalendarSettings() {
+export function CalendarSettings({ connect = false }: { connect?: boolean } = {}) {
// Windows and Linux: calendars are pasted calendar links, connected and removed here (and in the first run)
const link = !!globalThis.window?.yogurt?.capabilities?.calendarLink
const [view, setView] = useState<Awaited<ReturnType<typeof window.yogurt.calendar.list>>>()
const [busy, setBusy] = useState(false)
const [error, setError] = useState(false)
const [open, setOpen] = useState(expanded || link)
- const [adding, setAdding] = useState(false)
+ const [form, setForm] = useState<'closed' | 'automatic' | 'requested'>('closed')
+ const adding = form !== 'closed'
const addButton = useRef<HTMLButtonElement>(null), restoreFocus = useRef(false)
- const closeForm = () => { restoreFocus.current = true; setAdding(false) }
+ const closeForm = () => { restoreFocus.current = true; setForm('closed') }
useEffect(() => {
if (!adding && !busy && restoreFocus.current) { restoreFocus.current = false; addButton.current?.focus({ preventScroll: true }) }
}, [adding, busy])
useEffect(() => {
- if (link && view && view.status !== 'error' && !view.calendars.length) setAdding(true)
+ // Offer the empty-state form without taking focus from navigation or a Settings deep link.
+ if (link && view && view.status !== 'error' && !view.calendars.length) setForm(current => current === 'closed' ? 'automatic' : current)
}, [link, view?.status, view?.calendars.length])
+ useEffect(() => {
+ if (connect) { setOpen(true); setForm('requested') }
+ }, [connect])
const reload = useCallback(() => {
void window.yogurt.calendar.list().then(setView, () => setView({ status: 'error', calendars: [], hideEventsWithoutCallLink: false }))
}, [])
@@ -82,14 +87,14 @@ export function CalendarSettings() {
{view && view.status !== 'error' && <div className="settings-calendar-add">
<button ref={addButton} type="button" data-testid="calendar-link-add" className="settings-row settings-disclosure"
aria-expanded={adding} aria-controls="settings-calendar-add" disabled={busy}
- onClick={() => { if (adding) closeForm(); else setAdding(true) }}>
+ onClick={() => { if (adding) closeForm(); else setForm('requested') }}>
<span className="settings-row-copy"><span className="settings-label">{t('Add a calendar by link')}</span>
{!link && <span className="settings-description block">{t("Calendars from the Mac's Calendar app appear above automatically.")}</span>}
</span><ChevronDown size={16} aria-hidden="true" />
</button>
<div id="settings-calendar-add" className="accordion" data-open={adding} inert={!adding || undefined} aria-hidden={!adding}>
<div><div className="settings-calendar-link">
- <CalendarLinkForm only={link ? undefined : 'other'} autoFocus={adding} onCancel={closeForm} onBusyChange={setBusy}
+ <CalendarLinkForm only={link ? undefined : 'other'} autoFocus={form === 'requested'} onCancel={closeForm} onBusyChange={setBusy}
onConnected={() => { closeForm(); reload() }} />
</div></div>
</div>
diff --git a/app/src/renderer/src/components/Modal.tsx b/app/src/renderer/src/components/Modal.tsx
index 23b4d90b..d71b4c56 100644
--- a/app/src/renderer/src/components/Modal.tsx
+++ b/app/src/renderer/src/components/Modal.tsx
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState, type ReactNode } from 'react'
import { Dialog } from '@animate-ui/react/primitives/base-ui/dialog'
import { MotionPopup } from './MotionPopup'
import { motion, useReducedMotion } from '../motion'
+import { useDialogFocus } from '../useDialogFocus'
export const ModalClose = Dialog.Close
@@ -14,8 +15,7 @@ export function Modal({ title, description, children, onCancel, busy = false, cl
const [open, setOpen] = useState(true)
const reduce = useReducedMotion()
useEffect(()=>{if(closing)setOpen(false)},[closing])
- const dialog = useRef<HTMLDivElement>(null)
- const opener = useRef(document.activeElement instanceof HTMLElement ? document.activeElement : null)
+ const { popup, popupRef } = useDialogFocus()
const cancel = useRef(onCancel)
cancel.current = onCancel
useEffect(() => {
@@ -30,11 +30,11 @@ export function Modal({ title, description, children, onCancel, busy = false, cl
}}>
<Dialog.Portal keepMounted container={container}>
<Dialog.Backdrop className="app-modal-backdrop no-drag" transition={{ ease: motion.out, duration: (reduce ? motion.micro : motion.surface) / 1000 }} exitTransition={{ ease: motion.out, duration: (reduce ? motion.micro : motion.base) / 1000 }} />
- <MotionPopup ref={dialog} data-testid={testId} role={role} aria-modal="true" aria-busy={busy || undefined}
- className="app-modal no-drag" finalFocus={opener} initialFocus={() => {
- const first = dialog.current?.querySelector<HTMLElement>('[data-dialog-focus], [data-dialog-cancel]')
+ <MotionPopup ref={popupRef} data-testid={testId} role={role} aria-modal="true" aria-busy={busy || undefined}
+ className="app-modal no-drag" finalFocus={false} initialFocus={() => {
+ const first = popup.current?.querySelector<HTMLElement>('[data-dialog-focus], [data-dialog-cancel]')
if (first instanceof HTMLInputElement) first.select()
- return first ?? dialog.current
+ return first ?? popup.current
}}>
<div className="modal-copy">
<Dialog.Title>{title}</Dialog.Title>
diff --git a/app/src/renderer/src/components/NoteDate.tsx b/app/src/renderer/src/components/NoteDate.tsx
index ab2e6300..8ad69653 100644
--- a/app/src/renderer/src/components/NoteDate.tsx
+++ b/app/src/renderer/src/components/NoteDate.tsx
@@ -237,6 +237,7 @@ export class NoteDateBody extends Component<{ view: string; children: ReactNode
const copy = body.cloneNode(true) as HTMLDivElement
copy.inert = true; copy.setAttribute('aria-hidden', 'true')
copy.querySelectorAll('[id],[data-testid],[autofocus]').forEach(node => { node.removeAttribute('id'); node.removeAttribute('data-testid'); node.removeAttribute('autofocus') })
+ copy.querySelectorAll('[data-focus-ring],[data-quiet-focus]').forEach(node => { node.removeAttribute('data-focus-ring'); node.removeAttribute('data-quiet-focus') })
copy.classList.add('note-date-retiring')
return { height: shell.getBoundingClientRect().height, copy }
}
diff --git a/app/src/renderer/src/components/Search.tsx b/app/src/renderer/src/components/Search.tsx
index e183812d..10be5c88 100644
--- a/app/src/renderer/src/components/Search.tsx
+++ b/app/src/renderer/src/components/Search.tsx
@@ -1,3 +1,4 @@
+import { useDialogFocus } from '../useDialogFocus'
import { Dialog } from '@animate-ui/react/primitives/base-ui/dialog'
import { MotionPopup } from './MotionPopup'
import { motion } from '../motion'
@@ -82,9 +83,8 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
return () => clearTimeout(timer)
}, [q, scope, peopleKey, people, searchOptions.language, searchOptions.locale])
- // focus goes back where it was when search closes: read during the first render, before the input takes it
- const [before] = useState(() => document.activeElement as HTMLElement | null)
- useEffect(() => () => { seq.current++; if (before?.isConnected) before.focus({ preventScroll: true }) }, [before])
+ const { popupRef } = useDialogFocus()
+ useEffect(() => () => { seq.current++ }, [])
const input = useRef<HTMLInputElement>(null)
const highlight = useRef<HTMLDivElement>(null)
const syncHighlight = () => { if (highlight.current && input.current) highlight.current.scrollLeft = input.current.scrollLeft }
@@ -203,7 +203,7 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
<Dialog.Root open={open} onOpenChange={setOpen}>
<Dialog.Portal keepMounted>
<Dialog.Backdrop className="search-backdrop no-drag fixed inset-0 z-[100]" transition={{ ease: motion.out, duration: motion.micro / 1000 }} exitTransition={{ ease: motion.out, duration: motion.micro / 1000 }} />
- <MotionPopup initialFocus={input} finalFocus={() => before} data-testid="search" role="dialog" aria-modal="true" aria-label={t('Search and commands')} onKeyDown={onKeyDown}
+ <MotionPopup ref={popupRef} initialFocus={input} finalFocus={false} data-testid="search" role="dialog" aria-modal="true" aria-label={t('Search and commands')} onKeyDown={onKeyDown}
// a click anywhere in the panel keeps typing, arrows and Esc in the search box
onMouseDown={(e) => { if (e.target !== input.current) { e.preventDefault(); input.current?.focus() } }}
className="search-panel flex max-h-[74vh] w-full max-w-[640px] flex-col overflow-hidden rounded-2xl border border-line bg-float">
diff --git a/app/src/renderer/src/focusNavigation.ts b/app/src/renderer/src/focusNavigation.ts
new file mode 100644
index 00000000..59b11409
--- /dev/null
+++ b/app/src/renderer/src/focusNavigation.ts
@@ -0,0 +1,108 @@
+// A portal or native dialog has its own navigation history, even when it lives under document.body.
+const surfaceSelector = [
+ 'dialog', '[role="dialog"]', '[role="alertdialog"]', '[role="menu"]', '[role="toolbar"]',
+ '.menu-entry', '.ask-picker', '.citation-card', '.app-toast-viewport', '.transcript-find-clip',
+ '.calendar-link-form', '.note-date-picker', '.meeting-selection-bar', '.settings-screen', '.chat-page',
+ '.document-main', '.native-home', '.native-folder',
+].join(',')
+
+// The only element carrying the marker is the actual focus target.
+export const visibleFocus = ':focus-visible:not([data-quiet-focus]),[data-focus-ring]'
+
+export function installFocusNavigation(doc: Document) {
+ const page = doc.documentElement
+ const contrast = doc.defaultView?.matchMedia('(forced-colors: active), (prefers-contrast: more)')
+ const stack = [{ surface: page, keyboard: false }]
+ let marked: Element | null = null
+ let keyboardActivation = false
+ let navigating = false
+ let reset: ReturnType<typeof setTimeout> | undefined
+
+ function frame(el: Element, activated = false): { surface: HTMLElement; keyboard: boolean } {
+ const surface = el.closest<HTMLElement>(surfaceSelector) ?? page
+ const index = stack.findIndex(entry => entry.surface === surface)
+ if (index >= 0) stack.length = index + 1
+ else {
+ while (stack.length > 1 && !stack[stack.length - 1].surface.isConnected) stack.pop()
+ // A shortcut can enter a child before its containing screen has ever received focus.
+ const parent = surface.parentElement?.closest<HTMLElement>(surfaceSelector)
+ if (parent && !stack.some(entry => entry.surface === parent)) frame(parent)
+ stack.push({ surface, keyboard: activated || stack[stack.length - 1].keyboard })
+ }
+ return stack[stack.length - 1]
+ }
+
+ function mark(el: Element | null, keyboard: boolean) {
+ marked?.removeAttribute('data-quiet-focus')
+ marked?.removeAttribute('data-focus-ring')
+ marked = el
+ if (!el || el === doc.body || el === page) return
+ if (keyboard || (contrast?.matches && el.matches(':focus-visible'))) el.setAttribute('data-focus-ring', '')
+ else if (!contrast?.matches) el.setAttribute('data-quiet-focus', '')
+ }
+ function focus(event: FocusEvent) {
+ if (!(event.target instanceof Element)) return
+ if (event.target === page || event.target === doc.body || event.target.hasAttribute('data-base-ui-focus-guard')) return
+ const entry = frame(event.target, keyboardActivation)
+ keyboardActivation = false
+ if (navigating) entry.keyboard = true
+ mark(event.target, entry.keyboard)
+ }
+ function blur(event: FocusEvent) {
+ if (event.target === marked) mark(null, false)
+ }
+ function pointer(event: PointerEvent) {
+ if (!(event.target instanceof Element)) return
+ navigating = false
+ keyboardActivation = false
+ // Portal backdrops dismiss the dialog but do not belong to the page underneath.
+ if (event.target.matches('.search-backdrop,.app-modal-backdrop')) return
+ frame(event.target).keyboard = false
+ if (event.target.closest(surfaceSelector) === doc.activeElement?.closest(surfaceSelector)) mark(doc.activeElement, false)
+ }
+ function activate(event: MouseEvent) {
+ // A keyboard or assistive-technology press can enter a new menu without repainting its opener.
+ keyboardActivation = event.isTrusted && event.detail === 0
+ }
+ function key(event: KeyboardEvent) {
+ navigating = false
+ keyboardActivation = false
+ if (event.isComposing || !(event.target instanceof Element)) return
+ const jump = event.key === 'F6' || (event.key === 'F10' && (event.altKey || event.shiftKey)) || event.key === 'ContextMenu'
+ if (event.metaKey || event.ctrlKey || (event.altKey && !jump)) return
+ const travel = /^(Arrow(Up|Down|Left|Right)|Home|End)$/.test(event.key)
+ if (!jump && event.key !== 'Tab' && !travel) return
+ if (travel && event.target.closest('input,textarea,[contenteditable=true]')) {
+ const listKey = (event.key === 'ArrowDown' || event.key === 'ArrowUp') && event.target.matches('[role=combobox],[aria-activedescendant]')
+ if (!listKey && !event.target.matches('[type=range],[type=radio]')) return
+ }
+ // Tab can cross a surface boundary. F6 and F10 jump into another surface without changing the opener.
+ navigating = true
+ keyboardActivation = jump
+ clearTimeout(reset)
+ reset = setTimeout(() => { navigating = false }, 0)
+ if (!jump) {
+ frame(event.target).keyboard = true
+ mark(doc.activeElement, true)
+ }
+ }
+ function contrastChanged() {
+ if (doc.activeElement) mark(doc.activeElement, frame(doc.activeElement).keyboard)
+ }
+ contrast?.addEventListener('change', contrastChanged)
+ doc.addEventListener('focus', focus, true)
+ doc.addEventListener('blur', blur, true)
+ doc.addEventListener('pointerdown', pointer, true)
+ doc.addEventListener('keydown', key, true)
+ doc.addEventListener('click', activate, true)
+ return () => {
+ contrast?.removeEventListener('change', contrastChanged)
+ doc.removeEventListener('focus', focus, true)
+ doc.removeEventListener('blur', blur, true)
+ doc.removeEventListener('pointerdown', pointer, true)
+ doc.removeEventListener('keydown', key, true)
+ doc.removeEventListener('click', activate, true)
+ clearTimeout(reset)
+ mark(null, false)
+ }
+}
diff --git a/app/src/renderer/src/main.tsx b/app/src/renderer/src/main.tsx
index 57c651f4..c704b620 100644
--- a/app/src/renderer/src/main.tsx
+++ b/app/src/renderer/src/main.tsx
@@ -1,6 +1,7 @@
import { RendererGuard, RendererFailureTest } from './components/RendererGuard'
import { installNoteLifecycle } from './noteLifecycle'
import { installRendererErrors } from './rendererErrors'
+import { installFocusNavigation } from './focusNavigation'
import { installScrollActivity } from './scrollActivity'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
@@ -18,7 +19,7 @@ document.documentElement.classList.toggle('main-window', Which === App)
// Windows and Linux: the system's window buttons over the top right, no traffic lights (workspace.css)
if (window.yogurt.platform !== 'darwin') document.documentElement.dataset.chrome = 'overlay'
installRendererErrors()
-if (Which === App) { installScrollActivity(document); installNoteLifecycle() }
+if (Which === App) { installFocusNavigation(document); installScrollActivity(document); installNoteLifecycle() }
// everything re-renders in a newly picked language, in every window at once
function Page() { useLanguage(); return <Which /> }
const render = () => createRoot(document.getElementById('root')!).render(<StrictMode><RendererGuard><RendererFailureTest><Page /></RendererFailureTest></RendererGuard></StrictMode>)
diff --git a/app/src/renderer/src/meetingRowMotion.ts b/app/src/renderer/src/meetingRowMotion.ts
index d294e843..7487c1a0 100644
--- a/app/src/renderer/src/meetingRowMotion.ts
+++ b/app/src/renderer/src/meetingRowMotion.ts
@@ -53,7 +53,7 @@ export function captureMeetingRows(root: HTMLElement, next: MeetingCard[], pendi
const copy = el.cloneNode(true) as HTMLElement
// Exit copies are decoration, never a second focus target, drag source or test locator.
for (const node of [copy, ...copy.querySelectorAll<HTMLElement>('*')]) {
- for (const attr of ['id', 'data-testid', 'data-meeting-id', 'data-row-id', 'data-row-heading']) node.removeAttribute(attr)
+ for (const attr of ['id', 'data-testid', 'data-meeting-id', 'data-row-id', 'data-row-heading', 'data-focus-ring', 'data-quiet-focus']) node.removeAttribute(attr)
node.removeAttribute('draggable')
}
copy.inert = true
diff --git a/app/src/renderer/src/screens/Folder.tsx b/app/src/renderer/src/screens/Folder.tsx
index 20c7e4f4..bdf830a7 100644
--- a/app/src/renderer/src/screens/Folder.tsx
+++ b/app/src/renderer/src/screens/Folder.tsx
@@ -44,5 +44,5 @@ function FolderTitle({ folder }: { folder: FolderRow }) {
return <h1><input data-testid="folder-title-input" aria-label={t('Folder name')} autoFocus value={draft} maxLength={200}
onFocus={(e) => e.currentTarget.select()} onChange={(e) => setDraft(e.target.value)} onBlur={done}
onKeyDown={(e) => { if (e.key === 'Enter') e.currentTarget.blur(); else if (e.key === 'Escape') { cancelled.current = true; e.currentTarget.blur() } }}
- className="-mx-1 w-full rounded-lg bg-transparent px-1 outline-none ring-1 ring-line focus:ring-accent" /></h1>
+ className="-mx-1 w-full rounded-lg bg-transparent px-1 outline-none ring-1 ring-line focus-visible:ring-accent" /></h1>
}
diff --git a/app/src/renderer/src/screens/Note.tsx b/app/src/renderer/src/screens/Note.tsx
index f0c5c742..03259762 100644
--- a/app/src/renderer/src/screens/Note.tsx
+++ b/app/src/renderer/src/screens/Note.tsx
@@ -510,7 +510,7 @@ function Title({ id, title, editing, onEdit }: { id: string; title: string; edit
<input data-testid="note-title-input" aria-label={t('Title')} autoFocus value={draft} maxLength={200}
onFocus={(e) => e.currentTarget.select()} onChange={(e) => setDraft(e.target.value)} onBlur={done}
onKeyDown={(e) => { if (e.key === 'Enter') e.currentTarget.blur(); else if (e.key === 'Escape') { cancelled.current = true; e.currentTarget.blur() } }}
- className={`${cls} -mx-1 rounded-lg bg-transparent px-1 outline-none ring-1 ring-line focus:ring-accent`} />
+ className={`${cls} -mx-1 rounded-lg bg-transparent px-1 outline-none ring-1 ring-line focus-visible:ring-accent`} />
)
}
diff --git a/app/src/renderer/src/screens/Settings.tsx b/app/src/renderer/src/screens/Settings.tsx
index 6687b1f9..22b556e7 100644
--- a/app/src/renderer/src/screens/Settings.tsx
+++ b/app/src/renderer/src/screens/Settings.tsx
@@ -22,7 +22,7 @@ const loginLabel = () => osWords({ mac: t('Open Yogurt when your Mac starts'), w
const trayLabel = () => window.yogurt.os === 'win32' ? t('Show Yogurt in the notification area') : t('Show Yogurt in the tray')
/** Settings, kept small: what Yogurt may use, your name, open at login, stop when the call ends, light or dark, a backup and updates. Nothing technical. */
-/** focus: the setting a toast's Settings button opens, recordings or notes-model */
+/** focus: the setting requested by the entry point */
export function Settings({ revision = 0, focus }: { revision?: number; focus?: string }) {
const [perms, setPerms] = useState<PermissionStatus>()
const [prefs, setPrefs] = useState<{ theme: Theme; openAtLogin: boolean; showInMenuBar: boolean; appVisibility: AppVisibility; myName: string; macName: string; stopWhenCallEnds: boolean; recordingReminder: boolean; keepRecordings: boolean }>()
@@ -152,7 +152,7 @@ export function Settings({ revision = 0, focus }: { revision?: number; focus?: s
{supportedKinds(window.yogurt.capabilities).map((k) => <PermissionRow key={k} kind={k} status={perms?.[k]} onAsk={() => void window.yogurt.permissions.request(k).then(reload)} />)}
</ul></LoadingContent>
- {window.yogurt.capabilities.calendar && <CalendarSettings />}
+ {window.yogurt.capabilities.calendar && <CalendarSettings connect={focus === 'calendar'} />}
<h2 className="settings-section-heading">{t('Language')}</h2>
<div data-testid="settings-language" className="settings-group">
diff --git a/app/src/renderer/src/setup.css b/app/src/renderer/src/setup.css
index cb37e4fd..f0b813e5 100644
--- a/app/src/renderer/src/setup.css
+++ b/app/src/renderer/src/setup.css
@@ -49,7 +49,7 @@
.settings-backup-actions { display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:14px; }
.settings-backup-status { display:flex;flex-wrap:wrap;align-items:center;gap:5px 10px;margin-top:12px;font-size:12px;line-height:18px; }
.settings-jargon-field { position:relative;display:flex;flex-wrap:wrap;align-items:center;gap:5px;min-height:34px;margin-top:11px;padding:4px 5px;border:1px solid var(--line);border-radius:6px;background:var(--bg);cursor:text;transition:border-color var(--dur-micro) ease,box-shadow var(--dur-micro) ease; }
-.settings-jargon-field:focus-within { border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-soft); }
+.settings-jargon-field:has([data-focus-ring]) { border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-soft); }
.settings-jargon-input { flex:1;min-width:150px;height:24px;padding-inline:5px;background:transparent;color:var(--ink);font-size:13px;outline:none; }
.settings-jargon-input:focus-visible { outline:none; }
.settings-jargon-input::placeholder { color:var(--muted); }
diff --git a/app/src/renderer/src/styles.css b/app/src/renderer/src/styles.css
index a38ff318..34dace74 100644
--- a/app/src/renderer/src/styles.css
+++ b/app/src/renderer/src/styles.css
@@ -1,4 +1,5 @@
@import "tailwindcss";
+@custom-variant focus-visible (&:is([data-focus-ring],:focus-visible:where(:not([data-quiet-focus]))));
/* Brand type is bundled. Utility text follows macOS for a crisp native rhythm. */
@font-face {
@@ -232,16 +233,16 @@ html.widget { --pill:#232326;--pill-ink:#F7F7FA;--accent:#B780FF;--pill-accent:v
.note-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.person-remove { opacity: 0; }
.person-row:hover { background: color-mix(in srgb, var(--line) 45%, transparent); }
-/* keyboard focus shows a row's actions; the focus the card takes when it opens doesn't, so only the hovered row shows them */
-.person-row:hover .person-remove, .person-row:has(:focus-visible) .person-remove { opacity: 1; }
+/* The card may focus a name on open. Always reveal an action that receives focus itself. */
+.person-row:hover .person-remove, .person-row:has([data-focus-ring]) .person-remove, .person-remove:focus { opacity: 1; }
.menu-entry { transform-origin:var(--transform-origin, top right); }
/* Menus share the floating surface in each theme. */
.menu-entry[role="menu"] { color:var(--ink);border-color:var(--line);border-radius:9px;padding:5px;background:var(--float);box-shadow:var(--shadow); }
.menu-entry[role="menu"] :is([role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]) { min-height:32px;border-radius:5px;padding:6px 9px;font-size:12px;line-height:20px; }
.menu-entry[role="menu"] :is([role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]):hover:not(:disabled) { background:var(--control-hover); }
-.menu-entry[role="menu"] :is([role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"]):focus-visible { outline:none;background:var(--selected); }
+.menu-entry[role="menu"] :is([role="menuitem"], [role="menuitemradio"], [role="menuitemcheckbox"])[data-focus-ring] { outline:none;background:var(--selected); }
.menu-entry[role="menu"] :is([data-testid="note-delete"], .folder-picker-new) { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 5px 5px; padding-top: 10px; }
-.people-add-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
+.people-add-field:has([data-focus-ring]) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.people-add-field input:focus-visible { outline: none; }
.menu-entry[data-anchor="start"] { transform-origin: top left; }
[dir="rtl"] .menu-entry[data-anchor="start"] { transform-origin: top right; }
@@ -408,7 +409,7 @@ html.widget { --pill:#232326;--pill-ink:#F7F7FA;--accent:#B780FF;--pill-accent:v
[dir="rtl"] .scrubber::-webkit-slider-runnable-track { background: linear-gradient(to left, var(--accent) var(--fill), var(--line) var(--fill)); }
.scrubber::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 0 3px var(--float); }
.scrubber:focus-visible { outline: none; }
-.scrubber:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--float), 0 0 0 5px var(--accent); }
+.scrubber[data-focus-ring]::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--float), 0 0 0 5px var(--accent); }
@media (prefers-reduced-motion: reduce) {
.line-in, .name-in { animation:motion-fade var(--dur-micro) var(--ease-out); }
}
@@ -729,7 +730,7 @@ html:not(.widget) button:focus-visible, html:not(.widget) input:focus-visible {
.app-modal[data-testid=shortcuts-dialog] .modal-copy { flex:none;padding:22px 24px 18px; }
.shortcuts-close { position:absolute;inset-inline-end:16px;top:18px; }
.shortcuts-search { display:flex;align-items:center;gap:10px;margin:0 24px 12px;padding:9px 11px;border:1px solid var(--line);border-radius:7px;color:var(--muted); }
-.shortcuts-search:focus-within { border-color:var(--accent); }
+.shortcuts-search:has([data-focus-ring]) { border-color:var(--accent); }
.shortcuts-search input { width:100%;min-width:0;background:transparent;color:var(--ink);font-size:13px;outline:none; }
.shortcuts-list { flex:1;min-height:0;overflow-y:auto;padding:0 24px 22px; }
.shortcuts-list section+section { margin-top:20px; }
@@ -921,8 +922,8 @@ html:not(.widget) button:focus-visible, html:not(.widget) input:focus-visible {
.summary-stop-square { width:10px;height:10px;border-radius:2px;background:currentColor;opacity:0; }
.note-resume-action[data-processing=true] { cursor:pointer;box-shadow:0 1px 2px #0000000A; }
.note-resume-action[data-processing=true]:hover { background:var(--control-hover); }
-.note-resume-action:is(:hover,:focus-visible) .summary-stop-icon>svg { opacity:0; }
-.note-resume-action:is(:hover,:focus-visible) .summary-stop-square { opacity:1; }
+.note-resume-action:is(:hover,:focus) .summary-stop-icon>svg { opacity:0; }
+.note-resume-action:is(:hover,:focus) .summary-stop-square { opacity:1; }
.summary-stopped { display:flex;flex-direction:column;align-items:flex-start;gap:8px;color:var(--muted);font-size:13px; }
@media (prefers-reduced-motion:reduce) { .summary-stop-icon>* { transition:none; } }
@@ -988,7 +989,7 @@ html:not(.widget) button:focus-visible, html:not(.widget) input:focus-visible {
.audio-upload-month button:disabled { opacity:.25;cursor:default; }
.audio-upload-month button[data-outside=true] { opacity:.45; }
.audio-upload-month button:disabled:hover b { background:transparent; }
-.audio-upload-month button:focus-visible b { outline:2px solid var(--focus);outline-offset:1px; }
+.audio-upload-month button[data-focus-ring] b { outline:2px solid var(--focus);outline-offset:1px; }
.audio-upload-date-row .audio-upload-time { width:88px;min-width:0;height:32px;padding:0 8px;border:0;border-inline-start:1px solid var(--line);border-radius:0;background:transparent;flex:none;color:var(--ink);font-size:12px;font-variant-numeric:tabular-nums; }
.audio-upload-date:focus-visible,.audio-upload-time:focus-visible { outline:2px solid var(--focus);outline-offset:-2px; }
.audio-upload-time:hover:not(:disabled) { background:var(--control-hover); }
@@ -1031,3 +1032,7 @@ html:not(.widget) button:focus-visible, html:not(.widget) input:focus-visible {
:root.main-window .transcript-player-dock:not([data-hidden=true]) { clip-path:none; }
}
}
+
+/* Native and library focus returns can follow Escape or a click inside a different surface. */
+[data-quiet-focus]:focus-visible { outline-style:none !important; }
+:where([data-focus-ring]:not(:focus-visible)) { outline:2px solid var(--focus);outline-offset:2px; }
diff --git a/app/src/renderer/src/useCitationIntent.ts b/app/src/renderer/src/useCitationIntent.ts
index a55a0cb6..e4acaea8 100644
--- a/app/src/renderer/src/useCitationIntent.ts
+++ b/app/src/renderer/src/useCitationIntent.ts
@@ -1,3 +1,4 @@
+import { visibleFocus } from './focusNavigation'
import { useEffect, useRef } from 'react'
import { citationHover } from './citationHover'
@@ -49,7 +50,7 @@ export function useCitationIntent(options: Options) {
}
const focused = () => {
const active = document.activeElement
- return !!active && (popup()?.contains(active) || active.id === current.current.triggerId && active.matches(':focus-visible'))
+ return !!active && (popup()?.contains(active) || active.id === current.current.triggerId && active.matches(visibleFocus))
}
const closeHover = () => { if (current.current.open && !current.current.pinned) { popup(); current.current.close() } }
const valid = (element: HTMLElement) => !s.buttons && performance.now() >= s.scrollUntil && !selectionIn(element) && s.suppressed !== element.id
diff --git a/app/src/renderer/src/useDialogFocus.ts b/app/src/renderer/src/useDialogFocus.ts
new file mode 100644
index 00000000..d8359472
--- /dev/null
+++ b/app/src/renderer/src/useDialogFocus.ts
@@ -0,0 +1,30 @@
+import { useCallback, useEffect, useRef, useState } from 'react'
+import { visibleFocus } from './focusNavigation'
+
+type Opener = { target: HTMLElement; options: FocusOptions }
+const dialogOpeners = new WeakMap<Element, () => Opener | undefined>()
+
+export function useDialogFocus() {
+ const popup = useRef<HTMLDivElement>(null)
+ const [resolveOpener] = useState(() => {
+ const target = document.activeElement
+ if (!target || target === document.body || target === document.documentElement || !(target instanceof HTMLElement)) return () => undefined
+ const saved = { target, options: { preventScroll: true, focusVisible: target.matches(visibleFocus) } }
+ // Shortcut help can replace the palette while focus is still inside the outgoing dialog.
+ const parent = target.closest('[aria-modal="true"]')
+ const outer = parent && dialogOpeners.get(parent)
+ return () => saved.target.isConnected ? saved : outer?.()
+ })
+ const popupRef = useCallback((node: HTMLDivElement | null) => {
+ popup.current = node
+ if (node) dialogOpeners.set(node, resolveOpener)
+ }, [resolveOpener])
+ useEffect(() => () => {
+ queueMicrotask(() => {
+ if (document.activeElement !== document.body) return
+ const opener = resolveOpener()
+ opener?.target.focus(opener.options)
+ })
+ }, [resolveOpener])
+ return { popup, popupRef }
+}
diff --git a/app/src/renderer/src/workspace.css b/app/src/renderer/src/workspace.css
index 5fa850fb..a487a8f1 100644
--- a/app/src/renderer/src/workspace.css
+++ b/app/src/renderer/src/workspace.css
@@ -68,8 +68,8 @@
.workspace-folder-item [role=menuitem]:disabled { opacity:.4; }
.workspace-folder-item>.workspace-nav[data-drop=true] { background:var(--accent-soft);color:var(--ink); }
.workspace-folder-more { position:absolute;inset-inline-end:5px;top:4px;opacity:0; }
-.workspace-folder-item:hover .workspace-folder-more,.workspace-folder-more:focus-visible,.workspace-folder-more[aria-expanded=true] { opacity:1; }
-.workspace-folder-item:hover small,.workspace-folder-item:has(.workspace-folder-more:focus-visible,.workspace-folder-more[aria-expanded=true]) small { visibility:hidden; }
+.workspace-folder-item:hover .workspace-folder-more,.workspace-folder-more:focus,.workspace-folder-more[aria-expanded=true] { opacity:1; }
+.workspace-folder-item:hover small,.workspace-folder-item:has(.workspace-folder-more:focus,.workspace-folder-more[aria-expanded=true]) small { visibility:hidden; }
.workspace-folder-item small { position:absolute;inset-inline-end:var(--nav-inset); }
.workspace-folder-new,.workspace-folder-new>svg { color:var(--muted); }
.workspace-folder-new:hover { color:var(--ink); }
@@ -140,7 +140,7 @@
.native-meeting-day { margin-top:25px; }
.native-meeting-day>h2,.meeting-day-exit { font-size:10px;line-height:14px;font-weight:500;color:var(--muted);margin-bottom:9px; }
.native-meeting-row { position:relative;display:grid;grid-template-columns:minmax(0,1fr) max-content;align-items:center;column-gap:12px;margin-inline:-8px;padding-inline-end:8px;border-radius:7px;overflow:hidden; }
-.native-meeting-row:hover:not(:focus-visible):not(:has(:focus-visible)) { background:var(--row-hover); }
+.native-meeting-row:hover:not([data-focus-ring]):not(:has([data-focus-ring])) { background:var(--row-hover); }
.native-meeting-card { grid-area:1 / 1 / 2 / 3;display:grid;grid-template-columns:subgrid;align-items:center;min-width:0;border-radius:inherit; }
.native-meeting-card:has(.meeting-folder-pill) { grid-template-columns:minmax(0,1fr) fit-content(40%) max-content;column-gap:12px; }
.native-meeting-link { grid-area:1 / 1 / 2 / -1;display:grid;grid-template-columns:subgrid;align-items:center;width:100%;min-width:0;min-height:57px;padding-block:8px;padding-inline:8px 0;text-align:start;border-radius:inherit; }
@@ -159,16 +159,16 @@
.meeting-live { display:flex;align-items:center;gap:4px;color:var(--accent); }
.meeting-delete { opacity:.6; }
.meeting-delete svg { width:13px;height:13px; }
-.native-meeting-row:hover .meeting-delete,.native-meeting-row:has(:focus-visible) .meeting-delete { opacity:1; }
+.native-meeting-row:hover .meeting-delete,.native-meeting-row:has([data-focus-ring]) .meeting-delete,.meeting-delete:focus { opacity:1; }
.meeting-delete:hover { color:var(--danger); }
/* Opacity only: sliding text a couple of pixels re-rasterizes the glyphs, which reads as a jitter. The time leaves quickly and the button arrives just after, so the two never sit on top of each other. */
.row-swap-meta { grid-column:2;transition:opacity var(--dur-micro) var(--ease-out) 40ms; }
.row-swap-actions { grid-area:1 / 2;justify-self:end;z-index:1;opacity:0;pointer-events:none;transition:opacity var(--dur-micro) var(--ease-out); }
-.row-swap:is(:hover,:focus-visible,:has(:focus-visible),[data-menu-open=true],:has(>.row-swap-actions[aria-expanded=true])) .row-swap-meta { opacity:0;pointer-events:none;transition-delay:0ms; }
-.row-swap:is(:hover,:focus-visible,:has(:focus-visible),[data-menu-open=true],:has(>.row-swap-actions[aria-expanded=true])) .row-swap-actions { opacity:1;pointer-events:auto;transition:opacity var(--dur-micro) var(--ease-out) 50ms; }
+.row-swap:is(:hover,[data-focus-ring],:has([data-focus-ring],.row-swap-actions:focus-within),[data-menu-open=true],:has(>.row-swap-actions[aria-expanded=true])) .row-swap-meta { opacity:0;pointer-events:none;transition-delay:0ms; }
+.row-swap:is(:hover,[data-focus-ring],:has([data-focus-ring],.row-swap-actions:focus-within),[data-menu-open=true],:has(>.row-swap-actions[aria-expanded=true])) .row-swap-actions { opacity:1;pointer-events:auto;transition:opacity var(--dur-micro) var(--ease-out) 50ms; }
/* Pointer focus is inert; keyboard focus belongs to the whole row, inside its clipped boundary. */
-:is(.native-meeting-row,.ask-history-row,.agenda-event):is(:focus-visible,:has(:focus-visible)) { outline:2px solid var(--focus);outline-offset:-2px; }
-.native-meeting-row .native-meeting-link:focus-visible,.ask-history-row>.ask-history-link:focus-visible,.agenda-event .agenda-title:focus-visible { outline:none; }
+:is(.native-meeting-row,.ask-history-row,.agenda-event):is([data-focus-ring],:has([data-focus-ring])) { outline:2px solid var(--focus);outline-offset:-2px; }
+.native-meeting-row .native-meeting-link:is(:focus-visible,[data-focus-ring]),.ask-history-row>.ask-history-link:is(:focus-visible,[data-focus-ring]),.agenda-event .agenda-title:is(:focus-visible,[data-focus-ring]) { outline:none; }
.row-swap .workspace-icon:focus-visible { outline-offset:-2px; }
.meeting-row-menu { position:fixed;z-index:100;width:224px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);overflow-y:auto;border:1px solid var(--line); }
.meeting-row-menu [role="menuitem"] { display:flex;align-items:center;gap:10px;width:100%;text-align:start; }
@@ -206,7 +206,7 @@
.agenda-day>span { font-size:11px;color:var(--muted); }
.agenda-events { display:flex;flex-direction:column;gap:3px; }
.agenda-event { position:relative;display:grid;grid-template-columns:48px minmax(0,1fr);align-items:start;gap:12px;padding:8px 6px;border-radius:8px;overflow:hidden;cursor:pointer; }
-.agenda-event:hover:not(:has(:focus-visible)) { background:var(--row-hover); }
+.agenda-event:hover:not(:has([data-focus-ring])) { background:var(--row-hover); }
.agenda-event-body { display:flex;flex-direction:column;gap:2px;min-width:0;border-inline-start:2px solid var(--line);padding-inline-start:12px; }
.agenda-event:is(.live,[data-recording=true]) .agenda-event-body { border-inline-start-color:var(--accent); }
.agenda-event:is(.live,[data-recording=true]) .agenda-title { font-weight:600;letter-spacing:-.1px; }
@@ -276,7 +276,7 @@
/* The cited passage remains selectable text and keeps the same line boxes in every state. */
.citation-passage { display:inline;color:inherit;font:inherit;letter-spacing:inherit;text-align:inherit;white-space:normal;padding:1px 0;margin-inline:2px;border-radius:3px;box-decoration-break:clone;-webkit-box-decoration-break:clone;text-decoration-line:underline;text-decoration-style:dotted;text-decoration-color:color-mix(in srgb,var(--accent) 60%,transparent);text-decoration-thickness:1px;text-underline-offset:3px;text-decoration-skip-ink:auto;transition:background-color var(--dur-micro) ease,text-decoration-color var(--dur-micro) ease; }
.citation-passage,.citation-passage * { user-select:text;-webkit-user-select:text;cursor:text; }
-.citation-passage:is(:hover,:focus-visible,[aria-expanded=true]) { background:var(--accent-soft);text-decoration-color:var(--accent); }
+.citation-passage:is(:hover,[data-focus-ring],[aria-expanded=true]) { background:var(--accent-soft);text-decoration-color:var(--accent); }
.citation-passage:focus-visible { outline:2px solid var(--focus);outline-offset:1px; }
.citation-positioner { z-index:100; }
.citation-positioner[data-anchor-hidden] { visibility:hidden;pointer-events:none; }
@@ -477,7 +477,7 @@ body:has(.chat-panel[open]) .app-toast-viewport:dir(rtl) { --toast-x:440px; }
.orb-material::after { background:radial-gradient(ellipse at 68% 26%,#FFFFFF 0 3%,#CCB6FF 13%,transparent 40%),radial-gradient(ellipse at 23% 72%,var(--accent) 0 13%,#7142E8 29%,transparent 54%);animation-name:orb-counter;animation-duration:27s;opacity:.8; }
@keyframes orb-turn { from { transform:rotate(22deg); } to { transform:rotate(382deg); } }
@keyframes orb-counter { from { transform:rotate(-28deg); } to { transform:rotate(-388deg); } }
-.ask-box:not([data-busy=true]) .ask-send:not(:disabled):is(:hover,:focus-visible) { --orb-play:running;transform:scale(1.04); }
+.ask-box:not([data-busy=true]) .ask-send:not(:disabled):is(:hover,[data-focus-ring]) { --orb-play:running;transform:scale(1.04); }
.ask-send:active:not(:disabled) { transform:scale(.94); }
.ask-send:disabled { background:transparent;border-color:var(--line); }
.ask-send:disabled::after,.ask-send:disabled .orb-material,.ask-box[data-busy=true] .orb-material { display:none; }
@@ -531,7 +531,7 @@ body:has(.chat-panel[open]) .app-toast-viewport:dir(rtl) { --toast-x:440px; }
.ask-history section+section { margin-top:8px; }
.ask-history-empty { padding:16px 8px;color:var(--muted);font-size:12px; }
.ask-history-row { display:grid;grid-template-columns:minmax(0,1fr) max-content;align-items:center;column-gap:16px;height:46px;padding-inline:8px;border-radius:7px; }
-.ask-history-row:hover:not(:has(:focus-visible)) { background:var(--card); }
+.ask-history-row:hover:not(:has([data-focus-ring])) { background:var(--card); }
.ask-history-row:active { background:var(--control); }
.ask-history-link { grid-area:1 / 1 / 2 / 3;display:grid;grid-template-columns:subgrid;align-items:center;min-width:0;height:100%;text-align:start;border-radius:5px; }
.ask-history-link strong { min-width:0;font-size:13px;font-weight:450;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
diff --git a/app/src/shared/routes.ts b/app/src/shared/routes.ts
index 5075f9df..b4059f84 100644
--- a/app/src/shared/routes.ts
+++ b/app/src/shared/routes.ts
@@ -1,3 +1,3 @@
/** The renderer can navigate only within this workspace. */
export const isAppRoute = (route: unknown): route is string => typeof route === 'string' &&
- (['', '/meetings', '/chat', '/trash', '/settings', '/settings/recordings', '/settings/notes-model'].includes(route) || /^\/(?:note|chat|folder)\/[\w-]+$/.test(route))
+ (['', '/meetings', '/chat', '/trash', '/settings', '/settings/calendar', '/settings/recordings', '/settings/notes-model'].includes(route) || /^\/(?:note|chat|folder)\/[\w-]+$/.test(route))
diff --git a/app/test/agendaMarkers.test.ts b/app/test/agendaMarkers.test.ts
index ab93265b..457aac41 100644
--- a/app/test/agendaMarkers.test.ts
+++ b/app/test/agendaMarkers.test.ts
@@ -103,7 +103,7 @@ it('fades only ended, non-recording events, leaving row focus outlines at full s
expect(css.split(/\r?\n/).filter(line => line.includes('[data-faded=true]'))).toEqual([
'.agenda-event[data-faded=true] :is(.agenda-time,.agenda-title,.agenda-marker) { color:var(--ink);opacity:.65; }',
])
- expect(css).toContain(':is(.native-meeting-row,.ask-history-row,.agenda-event):is(:focus-visible,:has(:focus-visible)) { outline:2px solid var(--focus);outline-offset:-2px; }')
+ expect(css).toContain(':is(.native-meeting-row,.ask-history-row,.agenda-event):is([data-focus-ring],:has([data-focus-ring])) { outline:2px solid var(--focus);outline-offset:-2px; }')
})
it('shows people on live and recording rows without a Take notes action', () => {
diff --git a/app/test/calendarLinkForm.test.ts b/app/test/calendarLinkForm.test.ts
index 6b342550..07a11d8a 100644
--- a/app/test/calendarLinkForm.test.ts
+++ b/app/test/calendarLinkForm.test.ts
@@ -2,6 +2,7 @@ import {useState,useEffect,useRef,type ReactNode,type ReactElement} from 'react'
import {afterEach,expect,it,vi} from 'vitest'
import {CalendarLinkForm} from '../src/renderer/src/components/CalendarLinkForm'
import {CalendarSettings} from '../src/renderer/src/components/CalendarSettings'
+import {capabilities} from '../src/shared/platform'
import {calendarAddress} from '../src/shared/calendarLink'
import {LOCALES,setLanguage,t} from '../src/shared/i18n'
@@ -78,6 +79,7 @@ it.each([false,true])('restores Add focus after collapse and retains the mounted
vi.stubGlobal('window',{yogurt:{capabilities:{calendarLink:link},calendar:{list:async()=>view}},addEventListener:vi.fn(),removeEventListener:vi.fn()})
const h=harness(CalendarSettings);await Promise.resolve();h.run()
h.get('calendar-link-add').props.onClick();h.run();expect(h.get('calendar-link-add').props['aria-expanded']).toBe(true)
+ expect(h.type(CalendarLinkForm).props.autoFocus).toBe(true)
h.type(CalendarLinkForm).props.onCancel();h.run()
expect(h.get('calendar-link-add').props['aria-expanded']).toBe(false);expect(h.focus).toHaveBeenCalledWith({preventScroll:true})
expect(h.type(CalendarLinkForm)).toBeDefined();expect(h.all().find(e=>e.props.id==='settings-calendar-add')!.props.inert).toBe(true)
@@ -85,14 +87,30 @@ it.each([false,true])('restores Add focus after collapse and retains the mounted
h.type(CalendarLinkForm).props.onBusyChange(true);h.run();h.type(CalendarLinkForm).props.onConnected();h.run();expect(h.focus).not.toHaveBeenCalled()
h.type(CalendarLinkForm).props.onBusyChange(false);h.run();expect(h.focus).toHaveBeenCalledWith({preventScroll:true})
})
-it('opens the first link form on link-only platforms, but does not reopen it after Cancel',async()=>{
- const view={status:'notDetermined',calendars:[],hideEventsWithoutCallLink:false}
- vi.stubGlobal('window',{yogurt:{capabilities:{calendarLink:true},calendar:{list:async()=>view}},addEventListener:vi.fn(),removeEventListener:vi.fn()})
- const h=harness(CalendarSettings);await Promise.resolve();h.run();h.run()
- expect(h.get('calendar-link-add').props['aria-expanded']).toBe(true)
- h.type(CalendarLinkForm).props.onCancel();h.run();h.run()
- expect(h.get('calendar-link-add').props['aria-expanded']).toBe(false)
- expect(h.focus).toHaveBeenCalledWith({preventScroll:true})
+it.each(['win32', 'linux'])('keeps focus on Meetings when an empty calendar form appears in Settings on %s', async platform => {
+ const view = { status: 'notDetermined', calendars: [], hideEventsWithoutCallLink: false }
+ vi.stubGlobal('window', { yogurt: { capabilities: capabilities(platform), calendar: { list: async () => view } }, addEventListener: vi.fn(), removeEventListener: vi.fn() })
+ let connect = false
+ const settings = harness(() => CalendarSettings({ connect }))
+ await Promise.resolve()
+ settings.run()
+ settings.run()
+ expect(settings.get('calendar-link-add').props['aria-expanded']).toBe(true)
+ const form = harness(() => CalendarLinkForm(settings.type(CalendarLinkForm).props))
+ expect(form.focus).not.toHaveBeenCalled()
+ expect(settings.focus).not.toHaveBeenCalled()
+
+ // An explicit Connect calendar request can arrive while the empty form is already open.
+ connect = true
+ settings.run()
+ settings.run()
+ form.run()
+ expect(form.focus).toHaveBeenCalledExactlyOnceWith({ preventScroll: true })
+ settings.type(CalendarLinkForm).props.onCancel()
+ settings.run()
+ settings.run()
+ expect(settings.get('calendar-link-add').props['aria-expanded']).toBe(false)
+ expect(settings.focus).toHaveBeenCalledWith({ preventScroll: true })
})
it('translates the shorter instruction, validation and privacy line in all locales',()=>{
for(const {id} of LOCALES){setLanguage(id);for(const key of ['Copy the private iCal address from your calendar settings.','Enter an https:// or webcal:// calendar address.', 'The address stays on this computer.','Add a calendar by link',"Calendars from the Mac's Calendar app appear above automatically."]){expect(t(key).trim()).not.toBe('');if(id!=='en')expect(t(key)).not.toBe(key)}}
diff --git a/app/test/focusNavigation.test.ts b/app/test/focusNavigation.test.ts
new file mode 100644
index 00000000..8ebea3bf
--- /dev/null
+++ b/app/test/focusNavigation.test.ts
@@ -0,0 +1,126 @@
+import { readFileSync } from 'node:fs'
+import { afterEach, expect, it, vi } from 'vitest'
+import { installFocusNavigation } from '../src/renderer/src/focusNavigation'
+
+class Control {
+ readonly attributes = new Set<string>()
+ isConnected = true
+ parentElement?: Control
+ constructor(readonly surface?: Control, readonly textField = false) {}
+ closest(selector: string): Control | null {
+ if (selector.startsWith('dialog')) return this.surface ?? (this.attributes.has('surface') ? this : null)
+ return this.textField ? this : null
+ }
+ matches(selector: string) { return selector.includes('.search-backdrop') && this.attributes.has('backdrop') }
+ hasAttribute(name: string) { return this.attributes.has(name) }
+ setAttribute(name: string) { this.attributes.add(name) }
+ removeAttribute(name: string) { this.attributes.delete(name) }
+}
+
+afterEach(() => { vi.unstubAllGlobals(); vi.useRealTimers() })
+
+function fixture() {
+ vi.useFakeTimers()
+ vi.stubGlobal('Element', Control)
+ const body = new Control()
+ const doc = Object.assign(new EventTarget(), { documentElement: new Control(), body, activeElement: body })
+ const stop = installFocusNavigation(doc as unknown as Document)
+ function event(type: string, target: Control, props = {}) {
+ if (type === 'focus') doc.activeElement = target
+ const e = Object.assign(new Event(type), props)
+ Object.defineProperty(e, 'target', { value: target })
+ doc.dispatchEvent(e)
+ vi.runOnlyPendingTimers()
+ }
+ return { body, event, stop }
+}
+
+it.each([false, true])('restores the original search opener after typing and navigating inside (keyboard %s)', keyboard => {
+ const { body, event, stop } = fixture()
+ const opener = new Control(), input = new Control(new Control())
+ event(keyboard ? 'keydown' : 'pointerdown', keyboard ? body : opener, { key: 'Tab' })
+ event('focus', opener)
+ event('keydown', opener, { key: 'k', metaKey: true })
+ event('focus', input)
+ event('keydown', input, { key: 's' })
+ event('keydown', input, { key: 'ArrowDown' })
+ expect(input.attributes.has('data-focus-ring')).toBe(true)
+ event('keydown', input, { key: 'Escape' })
+ event('focus', opener)
+ expect(opener.attributes.has('data-focus-ring')).toBe(keyboard)
+ expect(opener.attributes.has('data-quiet-focus')).toBe(!keyboard)
+ expect(input.attributes.size).toBe(0)
+ event('keydown', opener, { key: 'Tab', shiftKey: true })
+ expect(opener.attributes.has('data-focus-ring')).toBe(true)
+ stop()
+ expect(opener.attributes.size).toBe(0)
+})
+
+it('retains each opener across nested menus and ignores typing, activation and dismissal', () => {
+ const { event, stop } = fixture()
+ const opener = new Control(), item = new Control(new Control()), action = new Control(new Control())
+ event('pointerdown', opener)
+ event('focus', opener)
+ event('focus', item)
+ for (const key of ['a', 'Enter', 'Escape']) {
+ event('keydown', item, { key })
+ expect(item.attributes.has('data-quiet-focus')).toBe(true)
+ }
+ event('keydown', item, { key: 'ArrowDown' })
+ event('focus', action)
+ event('pointerdown', action)
+ event('focus', item)
+ expect(item.attributes.has('data-focus-ring')).toBe(true)
+ event('focus', opener)
+ expect(opener.attributes.has('data-quiet-focus')).toBe(true)
+ event('blur', opener)
+ expect(opener.attributes.size).toBe(0)
+ stop()
+})
+
+it('keeps a keyboard opener visible when the backdrop is clicked', () => {
+ const { body, event, stop } = fixture()
+ const opener = new Control(), input = new Control(new Control()), backdrop = new Control()
+ backdrop.setAttribute('backdrop')
+ event('keydown', body, { key: 'Tab' })
+ event('focus', opener)
+ event('focus', input)
+ event('pointerdown', backdrop)
+ event('focus', opener)
+ expect(opener.attributes.has('data-focus-ring')).toBe(true)
+ stop()
+})
+
+it('keeps caret movement quiet and restores a previously unfocused containing screen', () => {
+ const { body, event, stop } = fixture()
+ const route = new Control(), panel = new Control()
+ route.setAttribute('surface')
+ panel.parentElement = new Control(route)
+ const textarea = new Control(panel, true), trigger = new Control(route)
+ event('keydown', body, { key: 'j', metaKey: true })
+ event('focus', textarea)
+ event('keydown', textarea, { key: 'ArrowLeft' })
+ expect(textarea.attributes.has('data-quiet-focus')).toBe(true)
+ event('keydown', textarea, { key: 'Tab' })
+ expect(textarea.attributes.has('data-focus-ring')).toBe(true)
+ const guard = new Control()
+ guard.setAttribute('data-base-ui-focus-guard')
+ event('focus', guard)
+ event('keydown', textarea, { key: 'Escape' })
+ event('focus', trigger)
+ expect(trigger.attributes.has('data-quiet-focus')).toBe(true)
+ stop()
+})
+
+it('reveals the focused action and clears overlapping metadata even when the focus ring is quiet', () => {
+ const style = readFileSync(new URL('../src/renderer/src/styles.css', import.meta.url), 'utf8')
+ const workspace = readFileSync(new URL('../src/renderer/src/workspace.css', import.meta.url), 'utf8')
+ expect(style).toMatch(/\.person-remove:focus\s*\{\s*opacity:\s*1;/)
+ expect(workspace).toMatch(/\.workspace-folder-more:focus,[^{]*\{ opacity:1;/)
+ expect(workspace).toMatch(/:has\(\.workspace-folder-more:focus,[^{]* small \{ visibility:hidden;/)
+ expect(workspace).toMatch(/\.meeting-delete:focus \{ opacity:1;/)
+ expect(workspace).toMatch(/\.row-swap-actions:focus-within[^{]* \.row-swap-actions \{ opacity:1;pointer-events:auto;/)
+ expect(workspace).toMatch(/\.row-swap-actions:focus-within[^{]* \.row-swap-meta \{ opacity:0;pointer-events:none;/)
+ expect(style).toMatch(/\.note-resume-action:is\(:hover,:focus\) \.summary-stop-square \{ opacity:1;/)
+ expect(style).toMatch(/:focus-within\) \.chat-answer-actions \{ opacity:1;/)
+})
diff --git a/app/test/motionInteractions.test.ts b/app/test/motionInteractions.test.ts
index a532dc3e..88eac8c2 100644
--- a/app/test/motionInteractions.test.ts
+++ b/app/test/motionInteractions.test.ts
@@ -1,5 +1,6 @@
import { afterEach, expect, it, vi } from 'vitest'
import { useEffect, useLayoutEffect, useRef, useState, type ReactElement, type ReactNode } from 'react'
+import { useDialogFocus } from '../src/renderer/src/useDialogFocus'
import { Search } from '../src/renderer/src/components/Search'
import { Ask } from '../src/renderer/src/components/Chat'
import { AskContext, scopeLabel } from '../src/renderer/src/components/AskContext'
@@ -34,6 +35,36 @@ function renderer(component: () => ReactNode) {
}
}
+it.each([false, true])('returns through a replaced dialog to the original opener (visible %s)', async keyboard => {
+ class Target {
+ isConnected = true
+ focus = vi.fn()
+ constructor(readonly dialog: Target | null = null) {}
+ matches() { return keyboard }
+ closest() { return this.dialog }
+ }
+ vi.stubGlobal('HTMLElement', Target)
+ const opener = new Target(), palette = new Target(), field = new Target(palette), help = new Target()
+ const doc = { activeElement: opener, body: new Target(), documentElement: new Target() }
+ vi.stubGlobal('document', doc)
+ function mount(popup: Target) {
+ renderer(() => { useDialogFocus().popupRef(popup as unknown as HTMLDivElement); return null })()
+ return vi.mocked(useEffect).mock.calls.at(-1)![0]() as () => void
+ }
+ const closePalette = mount(palette)
+ doc.activeElement = field
+ const closeHelp = mount(help)
+ field.isConnected = false
+ doc.activeElement = new Target(help)
+ closePalette()
+ await Promise.resolve()
+ expect(opener.focus).not.toHaveBeenCalled()
+ doc.activeElement = doc.body
+ closeHelp()
+ await Promise.resolve()
+ expect(opener.focus).toHaveBeenCalledExactlyOnceWith({ preventScroll: true, focusVisible: keyboard })
+})
+
it.each([
{ sidebarMotion: false, reduced: false },
{ sidebarMotion: true, reduced: false },
diff --git a/app/test/workspace.test.ts b/app/test/workspace.test.ts
index cbe8b468..0b253b2c 100644
--- a/app/test/workspace.test.ts
+++ b/app/test/workspace.test.ts
@@ -4,7 +4,7 @@ import { shiftDay, stepAgendaDay, weekDates, eventPhase } from '../src/renderer/
describe('workspace routes', () => {
it('accepts only local destinations and meeting IDs', () => {
- for (const route of ['', '/meetings', '/chat', '/trash', '/settings', '/settings/recordings', '/settings/notes-model', '/note/a-123', '/chat/c-123', '/folder/b-456']) expect(isAppRoute(route)).toBe(true)
+ for (const route of ['', '/meetings', '/chat', '/trash', '/settings', '/settings/calendar', '/settings/recordings', '/settings/notes-model', '/note/a-123', '/chat/c-123', '/folder/b-456']) expect(isAppRoute(route)).toBe(true)
for (const route of [null, 1, '/note/', '/note/../secrets', '/note/a?x=1', '/folder/', '/folder/../x', '/folders', '/settings/unknown', 'https://example.com', '/other']) expect(isAppRoute(route)).toBe(false)
})
})