Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multisearch array handling #132

Merged
merged 1 commit into from
Apr 12, 2024
Merged

Fix multisearch array handling #132

merged 1 commit into from
Apr 12, 2024

Conversation

jessarcher
Copy link
Member

While reviewing the issue raised in #130, I found some additional related issues with how the matches are determined after the user has selected something and then cleared the search field.

There were two main issues:

  1. Array destructuring doesn't preserve numeric keys even if they are strings and/or non-sequential, causing issues in some scenarios with search results that use numeric ID keys where the keys should be returned instead of the values. In this scenario, the + operator is preferable, but it's not safe to use with lists.
  2. array_is_list will return true on an empty array, so it's not safe to determine whether the selected values came from a list when the current $matches is empty. My solution is to capture whether $matches is a list the first time it is populated and use that for all future decisions.

This PR fixes these issues and also fixes the issue raised in #130 in a way that addresses the concerns I raised at #130 (comment).

Thanks to @macocci7 for finding the original issue and helping to solve it!

@taylorotwell taylorotwell merged commit e6f70bc into main Apr 12, 2024
7 checks passed
@taylorotwell taylorotwell deleted the multisearch-fixes branch April 12, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants