Page MenuHomePhabricator

Validate lemma length inline on input event
Closed, ResolvedPublic

Description

Use the error prop of the Wikit TextInput component to show an inline error if the lemma length exceeds a certain maximum length. Do this using the input event, i.e. as soon as the lemma becomes too long (rather than only on submit).

The length needs to be passed from WikibaseLexeme.git into the Vue app. Currently, the limit of 1000 (Unicode code points) is hard-coded in WikibaseLexeme.entitytypes.repo.php; making it configurable is beyond the scope of this task, but we might want to at least extract a PHP constant on some related class, so that we can refer to it in the ResourceLoader module definition without copying the value directly.

A preliminary message will be added at T305854#7937644, which should only be added for the dev entry point initially (i.e. in DevMessagesRepository.ts); the final message, to be translated as well, will be decided afterwards.

To count Unicode code points (rather than UTF-16 code units) of a string in JavaScript, we can use [ ...string ].length.

Event Timeline

Change 793749 had a related patch set uploaded (by Noa wmde; author: Noa wmde):

[mediawiki/extensions/WikibaseLexeme@master] LexiData: make max Lemma length available as a constant

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

Change 793749 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] LexiData: make max Lemma length available as a constant

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

I think NewLexemeAlpha.js still needs an update (together with the submodule + build).

Change 803507 had a related patch set uploaded (by Noa wmde; author: Noa wmde):

[mediawiki/extensions/WikibaseLexeme@master] Lexidata: add maxLemmaLength to init parameter list

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

Change 803507 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] Lexidata: add maxLemmaLength to init parameter list

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