You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the MyAutocompleteField implementation, the searchable_fields option includes translations.name and foo.translations.name. However, when both fields share the same name (name), the autocomplete search only uses the first occurrence (translations.name). If the order is reversed, the search instead targets foo.translations.name, which leads to inconsistent search results depending on the field order.
This behavior impacts the usability of the autocomplete functionality, as it prevents the search from working properly across both related entities.
Steps to reproduce:
Define searchable_fields as ['translations.name', 'foo.translations.name'].
Trigger the autocomplete field search.
Notice that only translations.name is used in the query.
Reverse the field order to ['foo.translations.name', 'translations.name'].
Now, only foo.translations.name is considered in the search.
Expected behavior:
The autocomplete should search across both translations.name and foo.translations.name fields, regardless of their order in searchable_fields.
Actual behavior:
The search query only considers the first occurrence of name in searchable_fields, ignoring the second field.
Proposed Solution:
Consider updating the query logic to handle multiple fields with the same name explicitly. This could involve aliasing the fields or extending the searchable_fields handling to ensure both translations.name and foo.translations.name are included in the search query.
Environment:
Symfony UX Autocomplete
Symfony Form Component
PHP 8.3
HugoSEIGLE
changed the title
[Autocomplete] (Searchable Fields): Incorrect Search Field Selection in Autocomplete Due to Similar Field Names
[Autocomplete] (Searchable Fields): Incorrect search field selection due to similar field names
Nov 13, 2024
Description:
In the MyAutocompleteField implementation, the searchable_fields option includes translations.name and foo.translations.name. However, when both fields share the same name (name), the autocomplete search only uses the first occurrence (translations.name). If the order is reversed, the search instead targets foo.translations.name, which leads to inconsistent search results depending on the field order.
This behavior impacts the usability of the autocomplete functionality, as it prevents the search from working properly across both related entities.
Steps to reproduce:
Expected behavior:
The autocomplete should search across both translations.name and foo.translations.name fields, regardless of their order in searchable_fields.
Actual behavior:
The search query only considers the first occurrence of name in searchable_fields, ignoring the second field.
Proposed Solution:
Consider updating the query logic to handle multiple fields with the same name explicitly. This could involve aliasing the fields or extending the searchable_fields handling to ensure both translations.name and foo.translations.name are included in the search query.
Environment:
Code :
The text was updated successfully, but these errors were encountered: