Page MenuHomePhabricator

Toolbar buttons that invoke dialogs insert text into incorrect text areas when there is more than one WikiEditor on a page
Closed, ResolvedPublic

Description

I have several text areas with WikiEditor toolbars attached on a single page. If I click the toolbar buttons that directly insert text into a text area, the inserted text goes in the correct text area. However, if I click the toolbar buttons that invoke a dialog (insert link, insert image, insert reference), the text goes to the same text area regardless of which toolbar the button was clicked on.

Event Timeline

cicalese raised the priority of this task from to Needs Triage.
cicalese updated the task description. (Show Details)
cicalese added a project: WikiEditor.
cicalese subscribed.

"I have several text areas with WikiEditor toolbars attached on a single page."
Where and how do you have this ? That's not a vanilla MediaWiki situation, so will require special care.

TheDJ triaged this task as Low priority.Feb 23 2016, 5:07 PM

I use SemanticForms, which allows you to use WikiEditor to edit text areas. If you have multiple text areas using WikiEditor on the same form, you will experience this problem.

Seb35 claimed this task.
Seb35 subscribed.

Yeah, I just tested with the master branch, and it is fixed.

The problem still exists with MW 1.28, WikiEditor 0.5.0 (ff440d6), and Page Forms 4.0.2 (627f35b).

To reproduce, create page Form:Test containing:

<includeonly>
{{{for template|Test}}}
{{{field|Field 1|input type=textarea|editor=wikieditor}}}
{{{field|Field 2|input type=textarea|editor=wikieditor}}}
{{{end template}}}
</includeonly>

Navigate to <wiki url>Special:FormEdit/Test/a. Click on the link button in the WikiEditor toolbar for one of the fields and add a link. If the link appears in the other text area, you’ve reproduced the bug. If the link appears in the correct text area, go to the other text area and repeat the link creation. You will see that the link shows up in the incorrect text area.

I confirm the bug still exists, it seems it is always added to the first text area; probably there is a global variable somewhere, which should not be global.

The bug occurs only for dialogs (link, image, etc.), it works correctly for direct buttons (bold, italics, special character, etc.). I would say it is more a WikiEditor bug than a PageForms bug, probably in the JS for the dialogs.

The issue is that PageForms initializes with some global config $.wikiEditor.modules.toolbar.config.getDefaultConfig() and in this sub-sub-object there is $.wikiEditor.modules.toolbar.fn.doAction( $( this ).data( 'context' ) .. (for insert-link; there are similar calls for other dialogs) but the object this is always the same, it should not.

I’m not sure how this should be properly fixed, it should be added somewhere a parameter, perhaps getDefaultConfig( context ), or retrieve somehow the origin of the dialog opening.

Seb35 removed Seb35 as the assignee of this task.Jan 19 2018, 8:33 PM

Could someone more knowlegeable in JS and WikiEditor take care of this? Debugging is done, it remains fixing properly the issue.

Could someone more knowlegeable in JS and WikiEditor take care of this? Debugging is done, it remains fixing properly the issue.

I can look at something like this, but please just link me a public instance where this occurs, that saves so much time.

I created https://sandbox.semantic-mediawiki.org/wiki/Form:TestWikiEditor that you should be able to test against by visiting https://sandbox.semantic-mediawiki.org/wiki/Special:FormEdit/TestWikiEditor/testpage. However, the version of PageForms installed there is incompatible with the version of WikiEditor installed there (0.5.2 (aea465f)), since the function WikiEditor.isSupported() was removed. I have submitted https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PageForms/+/476524 to fix PageForms to work with newer WikiEditor versions in a backward compatible manner. Once @Yaron_Koren is able to review/merge that patch and @Kghbln is able to update the sandbox wiki, this should be testable there.

@Kghbln, the patch to PageForms mentioned above has been merged. Could you please update PageForms on the sandbox wiki? Thank you!

@Kghbln, the patch to PageForms mentioned above has been merged. Could you please update PageForms on the sandbox wiki? Thank you!

Done. The wiki is now on PageForms master.

Done. The wiki is now on PageForms master.

Sorry. I had to revert back to the latest tag of Page Forms. Some installed composer extension (I am not sure which one) requires a stable version of Page Forms and now composer frantically tried to downgrade and broke my whole setup since it does not care if Page Forms was installed already.

Anyhow if the aim was to show that you can have to fields using WikiEditor in on form when it worked.

Note to self: This is because the dialogs are shared between editors... If a dialog was already opened before, it is reused the next time, even if it is from a different editor....

Ah, composer. @Kghbln, thanks for trying! @Yaron_Koren, will there be a new minor release of Page Forms at any point soon?

I guess I could release a new version of Page Forms at any time.... should I?

Yaron_Koren claimed this task.

I think this can finally be closed again...