codidact / qpixel

Q&A-based community knowledge-sharing software
https://codidact.com
GNU Affero General Public License v3.0
397 stars 68 forks source link

Tag synonym already exists error, when removing and re-adding with different capitalisation #1436

Open Wouter17 opened 1 month ago

Wouter17 commented 1 month ago

Describe the bug When removing a tag synonym, and re-adding it in the same action (so without hitting save), but with different capitalisation, it will give a "There were some errors while saving this tag: Tag synonyms A tag synonym with the name X already exists." (where the new tag name replaces X). It will also show both versions as being synonyms.

To Reproduce Steps to reproduce the behavior:

  1. Create a tag
  2. Add a synonym
  3. Remove the synonym (do not hit save)
  4. Add a version of the synonym with different capitalisation
  5. Press "Save"

Expected behavior The new capitalisation version is saved correctly.

Screenshots After removing the old one (AD) and adding the new one (ad) and pressing "save":

Error on tag edit page as described in "Describe the bug"

ArtOfCode- commented 1 month ago

Looks like this is expected behaviour. Tags with different capitalizations are considered the same tag, so it makes sense that synonyms would behave the same.

What's behind this issue? Has there been a case of a synonym not applying because someone created a tag with a different capitalization than the synonym used?

trichoplax commented 1 month ago

My impression from the issue description is that this is a problem with renaming a synonym during editing a tag itself, rather than changing the tags during editing a specific post.

I can reproduce the error. Here are my slightly more specific steps:

  1. Edit a tag to add a synonym.
  2. Save.
  3. Edit the same tag to remove the synonym (by pressing the "X" but not saving) and add a new synonym which has a different mix of upper and lower case.
  4. Save.
  5. See error.

Having a tag synonym with different case than you would like does not prevent it from functioning correctly. It will work regardless of what case a user saving a post enters. However, the system does already allow changing the case of a synonym, it just requires an additional save to make it work. For this reason it seems reasonable to improve the system, to allow making the change in a single step without saving in between.

The workaround in the meantime is as follows:

  1. Edit the tag to remove the synonym that you don't like the case of.
  2. Save.
  3. Edit the tag again to add the synonym with the case that you prefer.
  4. Save.

I believe that the intention of this issue is to avoid this need to save twice.

trichoplax commented 1 month ago

Although changing the case of a synonym is never necessary in order to make it work correctly, it seems reasonable to be able to change it for clarity or to fix typos that only affect case.

For example, if I edit the tag feature-request to make a synonym chANge-request, then anyone adding the tag change-request to a post will see it replaced with feature-request, so this works correctly. However, the case listed in the tag, with accidental upper case in the middle of chANge-request, could make someone wonder whether there is some reason for it. It would therefore be useful to be able to edit the tag synonym to instead say change-request (with no upper case), even though this is not essential in order for it to work correctly.

trichoplax commented 1 month ago

It's also possible that the error could give the impression that editing the case of a synonym is not possible, because the workaround by saving twice is not obvious.