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

Find and replace highlight sometimes jumps to the first item instead of next after replacing #16648

Open
f1ames opened this issue Jul 2, 2024 · 3 comments · May be fixed by #17292
Open

Find and replace highlight sometimes jumps to the first item instead of next after replacing #16648

f1ames opened this issue Jul 2, 2024 · 3 comments · May be fixed by #17292
Assignees
Labels
package:find-and-replace status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@f1ames
Copy link
Contributor

f1ames commented Jul 2, 2024

📝 Provide detailed reproduction steps (if any)

I'll start with videos since it illustrates this case nicely.

1st example works fine, and replace cycles nicely over words in order:

Screen.Recording.2024-07-02.at.11.43.35.mov

2nd and 3rd shows that highlight sometimes jumps to the first item:

Screen.Recording.2024-07-02.at.11.45.16.mov
Screen.Recording.2024-07-02.at.11.55.04.mov

Steps

As in 3rd video:

  1. Got to editor instance with Find and Replace enabled, e.g. https://ckeditor.com/docs/ckeditor5/42.0.0/features/find-and-replace.html.
  2. Use complex document, e.g. content from https://ckeditor.com/docs/ckeditor5/42.0.0/examples/builds/classic-editor.html.
  3. Open Find and Replace dialog.
  4. Type 'You' as "Find" and press "Find" button.
  5. Navigate to 5th result.
  6. Fill replace text and press replace.
  7. Press replace again.

✔️ Expected result

Replace should cycle over items in order.

❌ Actual result

Sometimes highlight jumps to first item.

❓ Possible solution

Not sure, I was suspecting complex structure and first item in a block/paragraph but was not able to confirm that with quick testing.

📃 Other details

  • Browser: Chrome
  • OS: MacOS
  • First affected CKEditor version: Not sure
  • Installed CKEditor plugins: Find and replace

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@rmoustgaard
Copy link

rmoustgaard commented Sep 16, 2024

This is simple to replicate without tracked changes:

  • Go to https://ckeditor.com/ckeditor-5/demo/feature-rich/
  • Replace all the text with "This doesn't work. This doesn't work. This doesn't work."
  • Open Find and Replace, and Find the word "work".
  • Click 'Next result' to skip the first occurrence.
  • Replace the second occurrence with another word.
  • Expected: Highlight/cursor moves to the third occurrence
  • Actual: Cursor jumps back to the first occurrence.

@lkszzajac
Copy link

The issue is reproducible in blocks that contain 2+ occurrences of queried sequence. If there is only one occurrence, the selection is moved as expected.

  • block with 1 occurrence:
one.occurrence.mov
  • block with 2 occurrences:
two.occurrences.mov

@lkszzajac lkszzajac added support:3 An issue reported by a commercially licensed client. support:2 An issue reported by a commercially licensed client. and removed support:3 An issue reported by a commercially licensed client. labels Sep 20, 2024
@Mati365 Mati365 self-assigned this Oct 18, 2024
@CKEditorBot CKEditorBot added the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Oct 21, 2024
@Mati365
Copy link
Member

Mati365 commented Oct 22, 2024

I proposed fix: #17292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:find-and-replace status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants