fix: improve robustness of search focus keyboard shortcut

- Update FontSelector to prevent '/' shortcut from triggering when another input is focused
- Ensure consistent behavior for '/' focus across Figlet and Units tools
This commit is contained in:
2026-02-23 08:05:33 +01:00
parent 81fa370ec9
commit 93bbc2ef22

View File

@@ -45,8 +45,14 @@ export function FontSelector({
const handleKeyDown = (e: KeyboardEvent) => {
// "/" to focus search
if (e.key === '/' && !e.ctrlKey && !e.metaKey) {
e.preventDefault();
searchInputRef.current?.focus();
const activeElement = document.activeElement;
if (
activeElement?.tagName !== 'INPUT' &&
activeElement?.tagName !== 'TEXTAREA'
) {
e.preventDefault();
searchInputRef.current?.focus();
}
}
// "Esc" to clear search
if (e.key === 'Escape' && searchQuery) {