16e0268da7
Image viewer (#609): - The next (▶) arrow was offset from the viewport edge (right:16px) so it floated over the 320px metadata side panel. Offset it off a shared --fc-side-w var so it sits at the image's right edge instead; full-width again below 900px when the panel stacks under the image. - Arrow nav was fully disabled whenever a text field was focused. Now it yields to the caret ONLY when the field has text; an empty tag-entry field still navigates ←/→. Extracted to utils/textEntry.js (arrowNavAllowed). ESC behaviour unchanged (already closes the modal, overlay-aware). Test: arrowNavAllowed — empty/non-text → navigate, text present → don't. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
// @vitest-environment happy-dom
|
|
import { describe, it, expect } from 'vitest'
|
|
|
|
import { arrowNavAllowed, hasText, isTextEntry } from '../src/utils/textEntry.js'
|
|
|
|
describe('textEntry helpers', () => {
|
|
it('navigates when the target is not a text field', () => {
|
|
expect(arrowNavAllowed(document.createElement('div'))).toBe(true)
|
|
expect(arrowNavAllowed(null)).toBe(true)
|
|
})
|
|
|
|
it('navigates when a focused tag input is empty', () => {
|
|
const input = document.createElement('input')
|
|
input.value = ''
|
|
expect(arrowNavAllowed(input)).toBe(true)
|
|
})
|
|
|
|
it('does NOT navigate when the input has text (caret moves instead)', () => {
|
|
const input = document.createElement('input')
|
|
input.value = 'naruto'
|
|
expect(arrowNavAllowed(input)).toBe(false)
|
|
})
|
|
|
|
it('isTextEntry / hasText recognise inputs and textareas', () => {
|
|
const ta = document.createElement('textarea')
|
|
ta.value = 'x'
|
|
expect(isTextEntry(ta)).toBe(true)
|
|
expect(hasText(ta)).toBe(true)
|
|
expect(isTextEntry(document.createElement('div'))).toBe(false)
|
|
})
|
|
})
|