Page MenuHomePhabricator

Middle click paste of a gloss language code is not correctly detected (causing the gloss to be discarded/deleted)
Open, Needs TriagePublic


If the gloss language code is pasted using middle click paste, the gloss is not saved

To reproduce:

  • Start editing an existing sense
  • Make a change to the existing gloss to activate the save link
  • Start adding another gloss
  • Middle click paste text into the language field
  • Enter some text into the gloss field
  • Save the sense

Expected behaviour: The new gloss is saved if the language code is valid, or an error is shown if it is not.

Actual behaviour: The change to the existing gloss is saved but the new gloss is silently discarded, whether the language code is valid or not.

Reproducible in Chromium-based browsers in Linux, not sure about other browsers.

Event Timeline

Nikki created this task.Dec 1 2020, 6:18 AM
Restricted Application added a project: Wikidata. · View Herald TranscriptDec 1 2020, 6:18 AM

Reproducible in Firefox 84 on Linux, and also when creating a new sense (as long as there’s at least one other gloss, so that there’s something to save).

Nikki added a comment.Fri, Jan 15, 1:18 PM

This just happened to me with nrf-je which is one of the language codes which doesn't appear in the dropdown at all, so there's no distinction between a successfully detected language code and one where it will silently discard your new gloss. :(

It seems there's two separate things happening:
It isn't detecting the middle click paste as entering text into the field, for some reason.
Instead of showing an error for a field it thinks is blank, it discards the entire row. I just created T272147 for that.

Nikki renamed this task from New gloss silently discarded if language code entered using middle click paste to Middle click paste of a gloss language code is not correctly detected (causing the gloss to be discarded/deleted).Fri, Jan 15, 1:26 PM
Nikki added a comment.Fri, Jan 15, 1:30 PM

It can also cause existing glosses to be deleted if you try to change the language:

  • Edit a sense with two or more glosses
  • Delete the text in one of the existing language name fields
  • Middle click paste a language code into the field instead
  • Click save
Nikki added a comment.EditedSat, Jan 16, 10:20 AM

I noticed that the dropdown is the same one used for monolingual text languages and - indeed - the one for monolingual text has the same problem with the language code not being detected on middle click paste. Although, thankfully, it's much less destructive there, since it mostly doesn't allow saving when it thinks a field is empty.

It can lose changes to the language though if you edit an existing statement. When the field is blank, it uses the initial value, so if you make some other change to the statement and you change the language by deleting the language and middle click pasting the new code, it won't save the change to the code.

It seems the input field only reacts to keydown events and naturally a middle click paste does not trigger a keydown event. I tried running $(".ui-suggester-input").on("input", function () { this.dispatchEvent(new Event("keydown")); }); in the console (after clicking edit, before doing anything else) and that made it behave as expected for me - so perhaps it should be reacting to input events instead of keydown events?