Page MenuHomePhabricator

Insert link dialog: After clicking the Cancel button, it does not insert a link if you press the Enter key
Open, Needs TriagePublicBUG REPORT

Description

What is the problem?

If I dismiss the "Insert link" dialog by clicking the "Cancel" button, on subsequent uses of the dialog pressing the Enter key will not insert a link. It will just dismiss the dialog without doing anything.

The dialog becomes much harder to use with a keyboard. You have to use the tab key to highlight the "Insert link" button and then press enter.

Clicking the "Insert link" button will work.

To get it working again you have to either:

  1. enter a valid link by clicking the "Insert link" button (for some reason this resets the state of the dialog)
  2. refresh the page

I have only been able to reproduce this on Firefox (78 and 95) and Chrome (87 and 96). I have not been able to reproduce this on Safari 14.

Steps to reproduce problem
  1. Open any article with the WikiEditor (e.g. https://en.wikipedia.beta.wmflabs.org/w/index.php?title=Page_preview_of_using_the_translate_tag&action=edit)
  2. Click the "Insert link" menu item (tooltip is "Link")
  3. Click the "Cancel" button
  4. Open the dialog again
  5. Type something
  6. If a search dropdown appears, select anything (either with the mouse or the keyboard)
  7. Press the Enter key

Expected behavior: The link will be inserted into the wikitext (e.g. [[Link]]).
Observed behavior: Nothing is inserted.

Environment

Browser: Firefox 95 and Chrome 96.
Wiki(s): https://en.wikipedia.beta.wmflabs.org, MediaWiki 1.38.0-alpha (a23cbc1) 16:47, 4 January 2022, WikiEditor 0.5.3 (c9c494d) 07:28, 4 January 2022.
Editor, if applicable: WikiEditor

Event Timeline

This bug also happens when, instead of clicking "Cancel" you just tab to the "Cancel" button. For example:

  1. Open the "Insert link" dialog
  2. Press the Tab key 3 times, until the "Cancel" button is highlighted
  3. Send the cursor back to the first input (the one with the label "Target page or URL:"). You can do this by clicking on it or pressing the Shift+Tab key three times.
  4. Enter a page title
  5. Press the Enter key

Expected behavior: The link will be inserted into the wikitext (e.g. [[Link]]).
Observed behavior: Nothing is inserted.

I believe the issue is with lines 337-339 of modules/jquery.wikiEditor.dialogs.config.js. It appears to set the button that an Enter press invokes while the "Insert link" button is still disabled.

Change #1216225 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/WikiEditor@master] dialogs: reset `dialogaction` when opening dialogs

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

Change #1216225 merged by jenkins-bot:

[mediawiki/extensions/WikiEditor@master] dialogs: reset `dialogaction` when opening dialogs

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

Bhsd removed Bhsd as the assignee of this task.Jan 6 2026, 7:27 AM
Bhsd subscribed.

My patch only fixes the problem in the task description but not the problem mentioned in T298549#7706920.

My patch only fixes the problem in the task description but not the problem mentioned in T298549#7706920.

It still doesn't reset dialogAction when the Insert button is enabled. I wonder if it would be appropriate to simply reset it on all link state changes (i.e. after line 124).

It still doesn't reset dialogAction when the Insert button is enabled.

Could you explain what you mean?

It still doesn't reset dialogAction when the Insert button is enabled.

Could you explain what you mean?

There are several cases of what happens when is pressed, depending on the order of the steps before it:

  1. The case in T298549#11498444 ("Cancel" is highlighted, followed by a link being entered)
    • The dialog is canceled with no link entered. (The "Cancel" button was the last button focused.)
  2. A link is entered, then the user -cycles through all buttons back to the link field
    • The dialog is canceled with no link entered. (The "Cancel" button was the last button focused.)
  3. The same as 2, but in reverse (i.e. +).
    • The link is inserted. (The "Insert Link" button was the last button focused.)
  4. A link is entered with no buttons ever being focused.
    • The link is inserted. (The "Insert Link" button is the first button of the dialog.)

The solution could be as simple as clearing dialogAction once the button loses focus.

The solution could be as simple as clearing dialogAction once the button loses focus.

Sounds good to me! Please feel free to claim this task.

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

[mediawiki/extensions/WikiEditor@master] Remove dialogaction from insert link dialog once button loses focus

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