kobotoolbox / kpi

kpi is the (frontend) server for KoboToolbox. It includes an API for users to access data and manage their forms, question library, sharing settings, create reports, and export data.
https://www.kobotoolbox.org
GNU Affero General Public License v3.0
131 stars 177 forks source link

Bug: "Add Language" input won't let you add spaces to end of string #4453

Open LMNTL opened 1 year ago

LMNTL commented 1 year ago

Description

The "Add Language" input in the "Manage Translations" dialog doesn't play well with space characters.

Steps to Reproduce

  1. Edit a project, then choose "Manage Translations" from the "..." menu
  2. Click "Add Language"
  3. Try typing (not copying) "english (en)" in the language code box

Expected behavior

Language code box displays "english (en)".

Actual behavior

Language code box displays "english(en)" Typing a space at the end of the string does nothing. You can add spaces, but only from the middle of the string.

Additional details

We trim the string of spaces during onChange(), so that's probably why this is happening. Switching it to trim during onSubmit() would fix this.

jnm commented 1 year ago

Thanks for catching, @LMNTL :+1: One note: we wouldn't want English (en) in either the "Language name" or "Language code" boxes. The name should be English and the code should be en: image

However, "Language name" should definitely be changed to allow spaces without the shenanigans you observe, for example: image