Files
FabledCurator/frontend/test/textEntry.spec.js
T
bvandeusen 16e0268da7
CI / lint (push) Successful in 2s
CI / backend-lint-and-test (push) Successful in 11s
CI / frontend-build (push) Successful in 25s
CI / intimp (push) Successful in 3m35s
CI / intapi (push) Successful in 7m41s
CI / intcore (push) Successful in 8m23s
fix(modal): next arrow clears metadata panel + arrows work in empty tag input
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>
2026-06-04 06:37:16 -04:00

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)
})
})