Page MenuHomePhabricator

Search and Replace does not work when editing filters
Closed, ResolvedPublic

Description

  1. Open a filter (e.g. https://pt.wikipedia.org/wiki/Special:AbuseFilter/138)
  2. Press CTRL+F to open the search tool
  3. Fill in the find field with anything that is present in the filter e.g. "a"
  4. Fill in the replace field with e.g. "b"
  5. Replace all ocurrences
  6. Save the filter

Expected result
The changes are saved

Actual result
The changes are not saved, even though we can see the code was changed. If I open the JS console in Firefox, I see that $('#wpFilterRules').val() returns the old code instead of the updated version so the code which is highlighted is out of sync with the code in the textarea. I believe the extension should be using the module "jquery.textSelection" for interacting with the textarea.

Event Timeline

This wouldn't be solved by jquery.textSelection. Instead, the problem is that we sync the Ace editor and the invisible input field (which is then submitted) using a keyup event on the Ace div. However, when using search&replace the keyup event isn't fired, and thus the content is not synced. I'll look into it, but can't say if this will be easy enough to solve.

Change 457457 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Change events used with the Ace editor

https://gerrit.wikimedia.org/r/457457

Aye, it was easy :-) BTW, many thanks for reporting! That's a great bug report and I also love to see that these minor AbuseFilter features are used, making it easier to write better software.

Change 457457 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Change events used with the Ace editor

https://gerrit.wikimedia.org/r/457457