Adding new term reverts changes to existing terms

Created on 4 July 2018, over 6 years ago
Updated 24 October 2024, 5 months ago

I have a hierarchical vocabulary used by a term reference field. The field is optional, allows multiple, and has these settings:
- Do not allow creation of new items
- Do not force selection of deepest level

The bug is that any terms set to "None" aren't unselected if a term is added immediately after using "Add another one".

To reproduce the bug:

  1. Save one or many terms to a node.
  2. Edit the node.
  3. Set any number of terms to "None".
  4. Use "Add another one" to add a new term and save.

If you reverse this by adding your new terms first and then setting the old ones to "None", then it saves correctly.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States joshua.roberson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States mkindred

    This still seems to be an issue. The bug appears in multiple scenarios (not just when you set existing terms to 'None'), so I changed the title.

    As @deepakaryan1988 mentioned, if you add a new term after changing existing terms (terms that existed prior to the current edit), then the values for the edited terms are reverted to the pre-edit values. This change happens in the background such that it looks as though your edit is OK; you find out only after you save.

    Steps

    Adding new term reverts changes to existing terms:

    1. edit content with existing terms saved
    2. change existing terms
    3. add a new term
    4. save
    5. changes to existing terms are lost

    Saves OK if you add the new term before editing existing terms:

    1. edit content with existing terms saved
    2. add a new term
    3. change existing terms
    4. save
    5. changes to existing terms are saved

    I've created a video to demonstrate the bug in a fresh D10 install: https://odysee.com/241024_drupal_shs_bug:c

  • πŸ‡¨πŸ‡¦Canada JayDarnell Guelph, Ontario

    I'm having a much bigger problem where the add another item button doesn't work at all. I've tried the latest release for the 2.x and 3.x branch but no luck. Clicking the Add another item button causes the existing item to disappear and then reappear but no field is added for selecting additional items.

  • πŸ‡«πŸ‡·France herve.tubaldo

    Hello, any news on this issue?
    I have the same problem:

    • I created a content type with a single shs field (Allowed number of values: unlimited)
    • If I create a content and select 3 terms, the first selected is not saved
    • If I select only one term, it works fine
  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Please look at your browser console for js exceptions and report them if you have some related exceptions.

  • πŸ‡«πŸ‡·France herve.tubaldo

    Hello, thank you for your reply.

    I am using the "Claro" theme and I have no errors in my browser console.

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Hmm @jaydarnell reported that this was an issue with his admin theme however this should work with the Claro theme.

    What version of Drupal core are you using @herve.tubaldo?

  • πŸ‡«πŸ‡·France herve.tubaldo

    @jaydarbell had another issue, the "add another item" button didn't work at all for him, which is not my case. I have the same problem as @mkindred or the comments before.

    I am using Drupal 10.3.9

  • πŸ‡ΊπŸ‡ΈUnited States mkindred

    lmk if anyone needs anything further from me. While I'm probably not up to the task of creating a patch at the moment, I can test and provide more info regarding any potential theme implications, if necessary.

Production build 0.71.5 2024