glpi icon indicating copy to clipboard operation
glpi copied to clipboard

Feature/remove spaces around equipment names

Open RomainLvr opened this issue 1 year ago • 6 comments

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

RomainLvr avatar Jan 25 '24 10:01 RomainLvr

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.

Rom1-B avatar Jan 25 '24 11:01 Rom1-B

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.

trasher avatar Jan 26 '24 09:01 trasher

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 :

image

Rom1-B avatar Jan 31 '24 10:01 Rom1-B

@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 ?

cedric-anne avatar Jan 31 '24 14:01 cedric-anne

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)

orthagh avatar Jan 31 '24 14:01 orthagh

If there are doubts, then no, we should not edit user input.

trasher avatar Feb 01 '24 06:02 trasher