glpi
glpi copied to clipboard
Feature/remove spaces around equipment names
| Q | A |
|---|---|
| Bug fix? | no |
| New feature? | yes |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | !30801 |
Removal of spaces before and after equipment names when adding or modifying in database
The original request only concerned pasting, to prevent the user inadvertently selecting an extra space when copying. If we trim systematically, it removes the current possibility of entering a space. Even if it's irrelevant to me, I can imagine that some customers would like it.
As said in our internal chat, I do prefer the first PHP solution.
It's more robust and testable than a JS one first, and I'm pretty sure adding an extra (unbreakable)space besides any name would cause issue in most of the cases, even if it's not from a copy paste (It can cause issues in search, in API, in inventory, ...).
I really see no real use case we really want to keep those extra spaces.
If the field is modified after it has been saved, the user may not understand why what is saved is different from what was entered. This can lead to support tickets.
In case of use, for example: allowing a space at the beginning can allow an item to be displayed always at the beginning, as here with computer2 :
@orthagh What do you think about it? Should we trim only on form side, or should we trim space that surrounds every name field during the saving process ?
Don't know...
I agree with @trasher that any space around the name may be a bug rather a wanted naming. But people doing crazy stuff, I'm pretty sure someone will have this kind of thing.
I'm not satisfied either by the interception of paste mechanism.
But in fact, do we really want to fix people copy pasting spaces ? Is it our job ? I don't know a software doing this (apart ofering the CTRL+Shift+V shortcut)
If there are doubts, then no, we should not edit user input.