mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-31 07:35:24 +00:00
fix(file-manager): restore Ctrl/Cmd+F file search (#1472)
* fix(ci): build plugin SDK before dependent checks * fix(mysql): keep plugin settings scope indexes within limits * test(mysql): refresh reviewed plugin upgrade SQL * fix(file-manager): focus file search with Ctrl or Cmd F
This commit is contained in:
1 parent
5e02e30d0f
commit
2770f14a25
2 files changed
+139
No files matched your search
@@ -232,6 +232,43 @@ export function FileManagerToolbar({
|
||||
sidebarOpen = true,
|
||||
onToggleSidebar,
|
||||
}: FileManagerToolbarProps) {
|
||||
const searchInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleSearchShortcut = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.defaultPrevented ||
|
||||
!(event.ctrlKey || event.metaKey) ||
|
||||
event.altKey ||
|
||||
event.shiftKey ||
|
||||
event.key.toLowerCase() !== "f"
|
||||
)
|
||||
return;
|
||||
|
||||
const input = searchInputRef.current;
|
||||
if (!input) return;
|
||||
const visible =
|
||||
typeof input.checkVisibility === "function"
|
||||
? input.checkVisibility({ visibilityProperty: true })
|
||||
: input.offsetParent !== null;
|
||||
if (!visible) return;
|
||||
const active = document.activeElement;
|
||||
if (
|
||||
active !== input &&
|
||||
active?.closest(
|
||||
'input, textarea, [contenteditable="true"], [role="dialog"]',
|
||||
)
|
||||
)
|
||||
return;
|
||||
|
||||
event.preventDefault();
|
||||
input.focus();
|
||||
input.select();
|
||||
};
|
||||
document.addEventListener("keydown", handleSearchShortcut);
|
||||
return () => document.removeEventListener("keydown", handleSearchShortcut);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col shrink-0 mx-3 mt-3 border border-border bg-card">
|
||||
<div className="flex flex-row items-center justify-between px-3 py-2 gap-2">
|
||||
@@ -325,6 +362,7 @@ export function FileManagerToolbar({
|
||||
<div className="relative w-28 md:w-48">
|
||||
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground" />
|
||||
<Input
|
||||
ref={searchInputRef}
|
||||
placeholder={t("fileManager.searchFiles")}
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
|
||||
Reference in new issue
Block a user