Skip to content

Commit

Permalink
Fix find popup stuck in infinite loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Oct 10, 2024
1 parent 5880f6b commit 4e070cf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/common/components/view-popup/find-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ function FindPopup({ params, onChange, onFindNext, onFindPrevious, onAddAnnotati
const inputRef = useRef();
const preventInputRef = useRef(false);
const [query, setQuery] = useState(params.query);
const currentParamsRef = useRef();

currentParamsRef.current = params;

const debounceInputChange = useCallback(debounce(value => {
if (!inputRef.current) {
return;
}
let query = inputRef.current.value;
if (query !== params.query && !(query.length === 1 && RegExp(/^\p{Script=Latin}/, 'u').test(query))) {
onChange({ ...params, query, active: true, result: null });
if (query !== currentParamsRef.current.query && !(query.length === 1 && RegExp(/^\p{Script=Latin}/, 'u').test(query))) {
onChange({ ...currentParamsRef.current, query, active: true, result: null });
}
}, DEBOUNCE_FIND_POPUP_INPUT), [onChange]);

Expand Down

0 comments on commit 4e070cf

Please sign in to comment.