Page MenuHomePhabricator

Whitespace is stripped while typing when editing lexemes
Closed, ResolvedPublic5 Estimated Story Points

Description

Problem:
When editing Lexemes (Lemmas, Form representations or Sense glosses), whitespace is stripped while typing. This means I keep losing spaces or deleting too many characters when trying to fix typos.
Elsewhere in Wikidata, whitespace is only stripped when saving. We should be consistent with that.

Steps to reproduce:

  • Edit a lemma, form or sense on a lexeme
  • Enter "cat dog" into the field
  • Backspace three times
  • Type "mouse"

Expected result: The field contains "cat mouse" because I only deleted three characters
Actual result: The field contains "catmouse"

The same behaviour happens at the beginning of the string if you use the delete key instead.

Acceptance criteria:

  • whitespace is only stripped at the beginning and end of words on saving, not while typing

Event Timeline

Just noticed the same thing while editing local test data to verify T267023 (Firefox 83).

(Edit: that was for sense glosses only, I didn’t realize this also affected lemmas and form representations.)

noarave set the point value for this task to 5.Dec 15 2020, 2:16 PM

Change 650161 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Don’t trim strings in JS

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

Change 650475 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Update representations and glosses after save

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

With https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikibaseLexeme/+/650475 the UI will correctly show trimmed whitespace for representations and glosses after saving, but not for lemmas. This isn't currently possible since wbeditentity doesn't contain the lemma data in its response. I created T271105 for that.

Change 650161 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Don’t trim strings in JS

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

Change 650475 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Update representations and glosses after save

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

@i_amy and I tested this. It all seems to work fine except one thing: the whitespace at the end of a Lemma is not stripped when saving. This should not happen. Based on Jakob's earlier comment I assume we need T271105 to fix this. Keeping this ticket open until it is solved.

@i_amy and I tested this. It all seems to work fine except one thing: the whitespace at the end of a Lemma is not stripped when saving. This should not happen. Based on Jakob's earlier comment I assume we need T271105 to fix this. Keeping this ticket open until it is solved.

Do you mean that the whitespace is still there when you edit the lemma again before reloading the page, or that the edit is actually saved with whitespace at the end and the whitespace persists even after reloading? T271105 would help with the former case, otherwise we have a more serious bug.

You're right. After a reload of the page the whitespace is no longer there. So that's good. I'm inclined to keep this ticket open until we have solved T271105 and used its result.

Moving this out of stalled because the necessary work in T271105 has now been done and we can work on the remaining issue of whitespace still being there in the following sequence:
1: edit lemma to contain a space at the end
2: save
3: click edit to edit the lemma again
4: see space at the end of the lemma that should not be there

(This only happens if you don't reload the page after step 2.)

Change 665107 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Update lemmas from wbeditentity response

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

Change 665108 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Synchronize state with LexemeHeader more consistently

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

Change 665107 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Update lemmas from wbeditentity response

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

Change 665108 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Synchronize state with LexemeHeader more consistently

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

I tested on the sandbox. but the space still exists.

Hnet-image.gif (144×600 px, 426 KB)

I tested on the sandbox. but the space still exists.

Hnet-image.gif (144×600 px, 426 KB)

Yes, the fix hasn’t been deployed yet. (It will hopefully be deployed later today.)

  NODES
Note 5
Project 9
Verify 1