mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
PR feedback
This commit is contained in:
@@ -213,8 +213,7 @@ export default function FindAndReplace({
|
|||||||
}, [caseSensitive, editor.commands, searchTerm]);
|
}, [caseSensitive, editor.commands, searchTerm]);
|
||||||
|
|
||||||
// Searching the document on every keystroke is expensive in long documents –
|
// Searching the document on every keystroke is expensive in long documents –
|
||||||
// it traverses the entire doc and rebuilds highlights – so debounce it to keep
|
// it traverses the entire doc and rebuilds highlights – so debounce.
|
||||||
// typing in the input responsive. The input value itself updates immediately.
|
|
||||||
const debouncedFind = React.useMemo(
|
const debouncedFind = React.useMemo(
|
||||||
() =>
|
() =>
|
||||||
debounce(
|
debounce(
|
||||||
@@ -225,7 +224,7 @@ export default function FindAndReplace({
|
|||||||
}) => {
|
}) => {
|
||||||
editor.commands.find(attrs);
|
editor.commands.find(attrs);
|
||||||
},
|
},
|
||||||
100
|
250
|
||||||
),
|
),
|
||||||
[editor.commands]
|
[editor.commands]
|
||||||
);
|
);
|
||||||
@@ -355,6 +354,9 @@ export default function FindAndReplace({
|
|||||||
} else {
|
} else {
|
||||||
onClose();
|
onClose();
|
||||||
setShowReplace(false);
|
setShowReplace(false);
|
||||||
|
// Cancel any pending debounced find so it can't reactivate highlights
|
||||||
|
// after the search has been cleared.
|
||||||
|
debouncedFind.cancel();
|
||||||
editor.commands.clearSearch();
|
editor.commands.clearSearch();
|
||||||
}
|
}
|
||||||
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -370,7 +372,10 @@ export default function FindAndReplace({
|
|||||||
>
|
>
|
||||||
<ButtonLarge
|
<ButtonLarge
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={() => editor.commands.prevSearchMatch()}
|
onClick={() => {
|
||||||
|
debouncedFind.flush();
|
||||||
|
editor.commands.prevSearchMatch();
|
||||||
|
}}
|
||||||
aria-label={t("Previous match")}
|
aria-label={t("Previous match")}
|
||||||
>
|
>
|
||||||
<CaretUpIcon />
|
<CaretUpIcon />
|
||||||
@@ -379,7 +384,10 @@ export default function FindAndReplace({
|
|||||||
<Tooltip content={t("Next match")} shortcut="Enter" placement="bottom">
|
<Tooltip content={t("Next match")} shortcut="Enter" placement="bottom">
|
||||||
<ButtonLarge
|
<ButtonLarge
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={() => editor.commands.nextSearchMatch()}
|
onClick={() => {
|
||||||
|
debouncedFind.flush();
|
||||||
|
editor.commands.nextSearchMatch();
|
||||||
|
}}
|
||||||
aria-label={t("Next match")}
|
aria-label={t("Next match")}
|
||||||
>
|
>
|
||||||
<CaretDownIcon />
|
<CaretDownIcon />
|
||||||
|
|||||||
@@ -410,8 +410,8 @@ export default class FindAndReplaceExtension extends Extension<FindAndReplaceOpt
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if already exists in results, possible due to duplicated
|
// Check if already exists in results, possible because we search
|
||||||
// search string on L257
|
// over `deburr(text) + text`
|
||||||
const key = `${from}:${to}`;
|
const key = `${from}:${to}`;
|
||||||
if (seen.has(key)) {
|
if (seen.has(key)) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user