mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
Picking a model closed the menu and then flashed the pill's tooltip over the fresh selection. The existing focus guard gated on `:focus-visible` alone, which does not separate a mouse pick from a Tab: the dropdown autofocuses its search field and keyboard-navigates its rows, so Chromium is already in keyboard modality when the menu restores focus to the trigger, and the guard never fired. Track the device behind the last real interaction and use it to qualify `:focus-visible`. A mouse pick reports `pointer` and stays silent; Tab focus still opens the tip.
31 lines
903 B
TypeScript
31 lines
903 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { lastInputModality } from './input-modality'
|
|
|
|
describe('lastInputModality', () => {
|
|
it('defaults to keyboard before any input', () => {
|
|
expect(lastInputModality()).toBe('keyboard')
|
|
})
|
|
|
|
it('tracks the device behind the last interaction', () => {
|
|
document.dispatchEvent(new Event('pointerdown'))
|
|
|
|
expect(lastInputModality()).toBe('pointer')
|
|
|
|
document.dispatchEvent(new Event('keydown'))
|
|
|
|
expect(lastInputModality()).toBe('keyboard')
|
|
})
|
|
|
|
it('sees events a handler stops from bubbling (capture phase)', () => {
|
|
const target = document.createElement('button')
|
|
|
|
document.body.append(target)
|
|
target.addEventListener('pointerdown', event => event.stopPropagation())
|
|
target.dispatchEvent(new Event('pointerdown', { bubbles: true }))
|
|
|
|
expect(lastInputModality()).toBe('pointer')
|
|
|
|
target.remove()
|
|
})
|
|
})
|