// Helpers for deciding whether a keyboard shortcut should fire or yield to a // focused text field. export function isTextEntry (el) { if (!el) return false const tag = el.tagName return tag === 'INPUT' || tag === 'TEXTAREA' || el.isContentEditable } export function hasText (el) { if (!el) return false if (el.isContentEditable) return (el.textContent || '').length > 0 return (el.value || '').length > 0 } // Prev/next arrow navigation should fire UNLESS focus is in a text entry that // already has content — in that case the arrows belong to the caret so it can // move through the text. An empty (or non-text) target still navigates. export function arrowNavAllowed (target) { return !(isTextEntry(target) && hasText(target)) }