Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: Allow searching when only the note viewer is visible and sync search with editor #10866

Conversation

personalizedrefrigerator
Copy link
Collaborator

Summary

This pull request fixes a Markdown editor issue originally reported on the Joplin forum — it was impossible to search a note when the note editor pane was hidden.

Remaining issues

  • It's possible for the Markdown viewer's search panel to be visible in the Rich Text editor. This is also an issue with the legacy editor prior to this pull request. To see this:
    1. Open the markdown editor.
    2. Hide the editor such that just the viewer is visible.
    3. Press ctrl-f such that the search bar is visible.
    4. Switch to the Rich Text Editor.

Screen recording

Screencast.from.2024-08-12.16-46-10.webm

Testing plan

Automated test: A new Playwright test has been added that verifies:

  • It's possible to search (local search) in the new markdown editor.
  • The search input remains visible after switching layouts such that the editor is hidden.
  • Changing the search in the markdown editor changes the matches in the viewer.
  • Changing the search when only the viewer is visible changes the highlighted matches.

Manual testing (Ubuntu 24.04):

  1. Create a note containing several instances of the word "test".
  2. Search globally for test.
  3. Open the note created in 1 from the note list.
  4. Open local search (ctrl-f).
  5. Verify that the local search query matches the global search query.
  6. Change the local search query. Verify that only the new matches are highlighted in both the viewer and editor.
  7. Close the local search panel.
  8. Verify that at least one copy of the original global search is highlighted in the viewer.
  9. Verify that all copies of the original global search are highlighted in the editor.

Regression testing: Mobile/web (Firefox):

  1. Create an empty note with test... Test. as its content.
  2. Press ctrl-f
  3. Verify that the search panel is visible.
  4. Search for test.
  5. Click "next".
  6. Verify that the selection moves to the next match.
  7. Open the advanced search options.
  8. Type "testing" in the "replace" input.
  9. Click "replace".
  10. Verify that the selected match has been replaced with "testing".
  11. Click "replace all".
  12. Verify that both matches have been replaced.
  13. Click '.*' (regex)
  14. Replace the text in the find input with t.*.
  15. Verify that all content is highlighted.
  16. Close the search menu by clicking the "x" button.
  17. Show the search menu by clicking the "🔍" button.
  18. Click on the note editor and press ctrl-f.
  19. Verify that the search menu is no longer visible.

Comment on lines +32 to +34
if (tr.effects.some(e => e.is(setSearchQuery)) || searchPanelOpen(tr.state) !== searchPanelOpen(tr.startState)) {
onSearchDialogUpdate(tr.state);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On mobile, this change leads to more information being sent over IPC while searching. This is because onSearchDialogUpdate fires an UpdateSearchDialog event, which now happens whenever the search query changes. Previously, UpdateSearchDialog events were fired only when the search dialog was opened/closed.

@laurent22 laurent22 merged commit b531306 into laurent22:dev Aug 15, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants