ckeditor / ckeditor4

The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.
https://ckeditor.com/ckeditor-4
Other
5.79k stars 2.47k forks source link

Text Watcher throttling called out of sync #2373

Open jacekbogdanski opened 5 years ago

jacekbogdanski commented 5 years ago

Type of report

Bug

Provide detailed reproduction steps (if any)

  1. Open console.
  2. Open manual test /tests/plugins/autocomplete/manual/throttle
  3. Type @anna.
  4. Remove insertion using backspace.

You may need to try a couple of times to get error result.

Expected result

No errors in a console.

Actual result

plugin.js?t=I6D6:7 Uncaught TypeError: Cannot read property 'element' of null
    at Object.CKEDITOR.plugins.textMatch.getRangeInText (plugin.js?t=I6D6:7)
    at Object.CKEDITOR.plugins.textMatch.match (plugin.js?t=I6D6:6)
    at b.callback (plugin.js?t=I6D6:6)
    at b.<anonymous> (plugin.js?t=I6D6:5)
    at c (ckeditor.js:27)

Other details

Buffered input function for textwatcher checks is called with a already modified range.

https://github.com/ckeditor/ckeditor-dev/blob/ddff49f8b81e8495c6741f1d536de3de28dc26ba/plugins/textwatcher/plugin.js#L246-L256

jbalinski commented 4 years ago

This issue is easily reproducible using the AutoComplete control with the default throttle of 200ms. Just typing a character and immediately hitting the backspace key will trigger the error. If we lower the throttle to below 50ms it seems to work around the issue but that is a suboptimal solution for those that are using a webservice call in conjunction with the AutoComplete control.