Problem/Motivation

Follow-up to #2317797: Comma in string (non-delimiter) creates multiple terms - see #10 for 7.x-2.2

According to the release notes, terms with commas are supported since 7.x-2.0-beta1 and the delimiter can be configured since 7.x-2.0-beta3.

I have found this is not true, when adding terms via Autocomplete Deluxe.
With the delimiter configured to be ";", entering a new string "Lorem Ipsum, Dolor" will show as a single tag in the UI, but when looking at the term list, 2 terms have been added: "Lorem Ipsum" and "Dolor".

Entering term

UI View

Term List

Proposed resolution

Rework autocomplete validation to use custom static function that imitates Drupal\Component\Utility\Tags::explode but uses delimiter that we specify in the form element. This way it works for new and existing terms.

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ➖ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ➖ Performance
  • ➖ Security
  • ➖ Documentation
  • ✅ Code review by maintainers
  • ➖ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Release notes snippet
  • ✅ Release autocomplete_deluxe-2.0.4

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • Issue #2903968: Fixed comma in string (non-delimiter) creates multiple terms
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

LNakamura created an issue. See original summary.

ataimist’s picture

Only a single term is created if the tag name containing commas is quoted (though this displays incorrectly in the UI as < The term ""tag, name"" will be added >, it will be created correctly as a single term with the comma in place and without the extra quotation marks).

Seems like this might be what Tags::explode(), which is used in AutocompleteDeluxeController::handleAutocomplete(), expects to be done for such tags. Didn't yet manage to figure out where to do it, though.

jweakley’s picture

Is it possible to have a choice as a user of this module if I want to have the values of a taxonomy term reference field be considered as having quotes around it or not? Why can't it be the default to just treat all characters in this field as being wrapper in quotes?

manuga’s picture

StatusFileSize
new1.25 KB

Possible solution

rajab natshah’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
garypigott39’s picture

StatusFileSize
new1.83 KB

So, that didnt work for me as it was losing some of the added tags in a multi-value field. I reworked it slightly and have attached the version that works for me in case it's of any use to someone.

sickness29’s picture

Status: Active » Needs review
StatusFileSize
new9.56 KB

I have reworked autocomplete validation to use custom static function that imitates Drupal\Component\Utility\Tags::explode but uses delimiter that we specify in the form element. This way it works for new and existing terms.

sickness29’s picture

  • sickness29 committed eed4c083 on 2.0.x
    Issue #2903968 by sickness29, manuga: Comma in string (non-delimiter)...
sickness29’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rajab natshah’s picture

Assigned: Unassigned » rajab natshah
Status: Closed (fixed) » Needs work
Issue tags: -autocomplete_deluxe-2.0.3 +autocomplete_deluxe-2.0.4
rajab natshah’s picture

Title: Comma in string (non-delimiter) creates multiple terms » Fix comma in string (non-delimiter) creates multiple terms
Issue summary: View changes
rajab natshah’s picture

Assigned: rajab natshah » Unassigned
Issue summary: View changes
Status: Needs work » Needs review

  • rajab natshah committed e832ea24 on 2.0.x
    Revert "Issue #2903968: Fix comma in string (non-delimiter) creates...
rajab natshah’s picture

Thanks, Andrew, for following on this issue.

Better to keep using the Drupal Core Autocomplete Validator to work with Drupal 10 and Drupal 11
Having custom validator will bring more issues ( reverted )

Committing the patch from #6 by Gary

  • rajab natshah committed f01b3396 on 2.0.x
    Issue #2903968: Fix comma in string (non-delimiter) creates multiple...
rajab natshah’s picture

Status: Needs review » Fixed
rajab natshah’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.