mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Filter query (#3740)
* Add search field to filter dialog * Add / shortcut to focus query * Fix f keybind typing f into query field * Document keyboard shortcut
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useRef } from "react";
|
||||
import { useRef, useEffect } from "react";
|
||||
|
||||
const useFocus = () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -14,4 +14,19 @@ const useFocus = () => {
|
||||
return [htmlElRef, setFocus] as const;
|
||||
};
|
||||
|
||||
// focuses on the element only once on mount
|
||||
export const useFocusOnce = () => {
|
||||
const [htmlElRef, setFocus] = useFocus();
|
||||
const focused = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!focused.current) {
|
||||
setFocus();
|
||||
focused.current = true;
|
||||
}
|
||||
}, [setFocus]);
|
||||
|
||||
return [htmlElRef, setFocus] as const;
|
||||
};
|
||||
|
||||
export default useFocus;
|
||||
|
||||
Reference in New Issue
Block a user