Open
Conversation
435818b to
b297cb5
Compare
…educe duplication with storybook stories
60489f4 to
b53bdfb
Compare
Comment on lines
+970
to
+976
| // Remove the find-result-highlight annotation when the editor changes or the find panel closes | ||
| useEffect(() => { | ||
| const currentController = editorWebViewController; | ||
| return () => { | ||
| currentController?.runAnnotationAction('find-current-result', 'removed').catch(() => {}); | ||
| }; | ||
| }, [editorWebViewController]); |
There was a problem hiding this comment.
🟡 Stale find-result-highlight annotation persists in editor after clearing search
When the user clears the search (clicks the X button), handleStopSearch(true) clears results and sets focusedResultIndex to undefined, but the find-result-highlight annotation set in handleFocusedResultChange (find.web-view.tsx:991-996) is never removed from the editor. The cleanup effect at find.web-view.tsx:970-976 only triggers when editorWebViewController changes or the component unmounts — not when search results are cleared. This leaves a stale yellow highlight on the last-focused result in the editor until the Find panel is closed or the editor changes.
Prompt for agents
In extensions/src/platform-scripture/src/find.web-view.tsx, the annotation cleanup effect at lines 970-976 only fires when editorWebViewController changes or the component unmounts. Add an additional effect (or extend the existing handleStopSearch logic) that removes the find-current-result annotation when focusedResultIndex becomes undefined while results are empty (i.e. after clearing). For example, add:
useEffect(() => {
if (focusedResultIndex === undefined && results.length === 0 && editorWebViewController) {
editorWebViewController.runAnnotationAction('find-current-result', 'removed').catch(() => {});
}
}, [focusedResultIndex, results.length, editorWebViewController]);
Alternatively, call the removal inside handleStopSearch by passing editorWebViewController into its dependency list, or trigger removal from the clear handler.
Was this helpful? React with 👍 or 👎 to provide feedback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://paratextstudio.atlassian.net/browse/PT-3897

Demo Video (had to zip it because it was just a little bit over the size limit for files):
replace-preview-options-picker.zip
This change is