Closed (fixed)
Project:
Tagify
Version:
1.2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 Jul 2024 at 19:19 UTC
Updated:
26 Jan 2025 at 17:47 UTC
Jump to comment: Most recent
When changing the label of a result to something completely different, or anytime a search result returned by Drupal does not contain the original search term, the result is not being shown in the dropdown, even though it's present in the entity autocomplete JSON response.
One way to reproduce this is to implement hook_tagify_autocomplete_match_alter() like this:
/**
* Implements hook_tagify_autocomplete_match_alter().
*/
function my_module_tagify_autocomplete_match_alter(?string &$label, ?string &$info_label, array $context): void
{
$label = 'Test';
}
Search for the original title of an entity. It should appear in the search results with 'Test' as label, but it doesn't.
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
Comment #2
dieterholvoet commentedThis would be fixed if we could somehow not let Tagify filter the results. So only Drupal does filtering, Tagify just shows the list of results that's returned by Drupal.
Comment #5
gxleano commentedComment #6
gxleano commentedThe same logic will be added to the Tagify User List module.
Comment #7
dieterholvoet commentedThat doesn't fix the problem in my use case. I should've been more clear, I'll explain. I have an Artist content type with an 'Alternative spellings' field. I wrote a custom entity reference selection handler that doesn't only search the title field, but also the alternative spellings field. So imagine there's a 'Foo' artist with 'Bar' in its alternative spellings. Now, when I search for 'Bar', the autocomplete endpoint returns the following data:
but the first result isn't shown in the widget. Isn't it possible to disable Tagify filtering the results? I don't see why that's necessary, since the backend does the filtering.
Comment #8
gxleano commentedIn my view, there are two distinct aspects here:
Bug Fix: The issue of matching results not appearing when a label is modified. This has been addressed in the current update. It appears that the label alteration feature wasn't functioning as expected, and the new logic now resolves this issue.
New Feature: The addition of alternative spellings or synonyms configuration for the Tagify widget. We can introduce a new configuration option in the widget that allows you to define alternative spellings or synonyms using tokens and specify the field that contains these variations.
So, I would create a new issue where add the requirements about the new feature.
Comment #9
gxleano commentedComment #10
dieterholvoet commentedNo, this is not what I asked. The alternative spellings feature is something I have in my own site, something that's completely handled within a custom entity reference selection handler. The only problem is that Tagify doesn't display a suggestion that's returned by Drupal if the search term is not contained in the suggestion. You can see that in the example JSON I embedded in my previous comment.
I just had a look myself and found an easy fix to make sure no results returned by Drupal are ever excluded from the Tagify dropdown.
Comment #12
dieterholvoet commentedI updated the issue title and description to be more clear.
Comment #14
gxleano commentedUnderstood, I will take a look into your changes.
Thanks!
Comment #15
gxleano commentedI've been testing the MR and it's working as expecting.
It will be included in
1.2.31release.Comment #16
gxleano commentedComment #17
gxleano commented