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.