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:
@@ -45,9 +45,15 @@ export function FontSelector({
|
|||||||
const handleKeyDown = (e: KeyboardEvent) => {
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
// "/" to focus search
|
// "/" to focus search
|
||||||
if (e.key === '/' && !e.ctrlKey && !e.metaKey) {
|
if (e.key === '/' && !e.ctrlKey && !e.metaKey) {
|
||||||
|
const activeElement = document.activeElement;
|
||||||
|
if (
|
||||||
|
activeElement?.tagName !== 'INPUT' &&
|
||||||
|
activeElement?.tagName !== 'TEXTAREA'
|
||||||
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
searchInputRef.current?.focus();
|
searchInputRef.current?.focus();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// "Esc" to clear search
|
// "Esc" to clear search
|
||||||
if (e.key === 'Escape' && searchQuery) {
|
if (e.key === 'Escape' && searchQuery) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user