ckeditor / ckeditor5

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
https://ckeditor.com/ckeditor-5
Other
9.37k stars 3.68k forks source link

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

Open f1ames opened 2 months ago

f1ames commented 2 months ago

📝 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:

https://github.com/cksource/ckeditor5-commercial/assets/1061942/678d2099-5e1a-4a77-acef-43c844cb4ca0

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

https://github.com/cksource/ckeditor5-commercial/assets/1061942/82279342-3e5f-446a-89bb-3b08bc81f928

https://github.com/cksource/ckeditor5-commercial/assets/1061942/0054df5f-27ed-4b23-9393-36c1f3c65059

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


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

rmoustgaard commented 1 week ago

This is simple to replicate without tracked changes:

lkszzajac commented 4 days ago

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.

https://github.com/user-attachments/assets/12e88a5a-02e0-45a6-9c56-810d6d7a28a0

https://github.com/user-attachments/assets/5afaccba-e61b-43b0-b5d7-f0360213a0a5