matrix-org / matrix-rich-text-editor

Matrix Rich Text Editor
https://matrix-org.github.io/matrix-rich-text-editor/
Apache License 2.0
82 stars 19 forks source link

Avoid dispatching to text watcher an empty text when calling replaceAll #940

Closed ganfra closed 4 months ago

ganfra commented 4 months ago

We have a custom InterceptInputConnection and to avoid messing up with selection/composition spans, we are calling sequentially :

editable.clear
editable.append

Which causes registered text watchers to get an empty string which shouldn't be dispatched.

This PR introduce a TextWatcher which can be temporary disabled.

I don't want the burden of filtering this events on the client side.

sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

ganfra commented 4 months ago

I'm not sure this is such a good idea as we might have some android code using the text watchers to do some stuff... So I'll close the PR and just let the clients handle a debounce if needed.