Page MenuHomePhabricator

WikiEditor can insert into the wrong textbox
Open, Needs TriagePublicBUG REPORT

Description

When the ProofreadPage headers/footers are open in Page namespace, using the WikiEditor character panels, and other tools, insert into the main text box, even if the cursor is in the header or footer.

Event Timeline

Actually this issue is not limited to Wikisource pages. If I click in the Edit Summary box, and then click Bold or Italic, text is inserted in the main text box, which clearly was not my intention, and may lead to errors, because in that moment I'm not watching the text box, I'm watching the edit summary, and I may not notice what just happened. WikiEditor should not insert in a box if the focus is not there.

It is worth noting that the CharInsert extension, responsible for the "edit tools" section generally present at most wikis at the bottom of the page, actually works with all textarea and input boxes, including the Edit summary, and it also works for the ProofreadPage header and footer boxes. It just puts the text where the focus is.

So it should be possible to apply the same logic to make WikiEditor also work in the same way. Aside from Wikisource, this could be useful in general: I know that wikitext syntax in the edit summary is limited, but I may need to insert some special characters or a link through the WikiEditor toolbar.

Candalua renamed this task from ProofreadPage: WikiEditor can insert into the wrong textbox to WikiEditor can insert into the wrong textbox.Apr 24 2025, 4:04 PM

I confirm and I think this is a bug, because it may insert wrong characters somewhere in the main Wikisource field, and the user may not notice it.

If I'm correct, that could be easily fixed by checking that the focus is inside the wpTextbox1 textarea before inserting or replacing characters at the caret position. Something like this in WikiEditor/modules/jquery.wikiEditor.toolbar.js:

.on( 'click', ( e ) => {
   if(document.activeElement.id != context.$textarea.attr("id")) {
    alert("This action cannot be used outside the main editing field");
    return false;
  }
  ...
}

This modification could be applied at line 575 in https://github.com/wikimedia/mediawiki-extensions-WikiEditor/blob/master/modules/jquery.wikiEditor.toolbar.js

Apologies for the earlier comment. I'll work on this issue in a moment.

Change #1277241 had a related patch set uploaded (by Happy5214; author: Happy5214):

[mediawiki/extensions/WikiEditor@master] Ignore most text modifications when main text area isn't focused

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

Test wiki created on Patch demo by TheDJ using patch(es) linked to this task:
https://14f5ef1563.catalyst.wmcloud.org/w/

Change #1277241 merged by jenkins-bot:

[mediawiki/extensions/WikiEditor@master] Ignore most text modifications when main text area isn't focused

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

@happy5214 @TheDJ The deployed patch did not help with this issue, yet causing new issues (T296396#12117120 and T431919).

Test wiki on Patch demo by TheDJ using patch(es) linked to this task was deleted:

https://14f5ef1563.catalyst.wmcloud.org/w/