Skip to content

[Bug Report][3.8.1] Autocomplete custom-filter displays broken results when function returns index of the match #21228

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

Closed
joshas opened this issue Apr 7, 2025 · 2 comments
Assignees
Labels
C: VAutocomplete T: bug Functionality that does not work as intended/expected
Milestone

Comments

@joshas
Copy link

joshas commented Apr 7, 2025

Environment

Vuetify Version: 3.8.1
Last working version: 3.7.19
Vue Version: 3.5.13
Browsers: Firefox 137.0
OS: Linux x86_64

Steps to reproduce

Enter "Ca" in search, observe that matched part of string is correctly highlighted.

Expected Behavior

Enter "a". All "a" letters in found results should be highlighted.

Actual Behavior

Strings in results are modified to include extra repeating parts of same strings. e.g. "Colorolorado" :)

Reproduction Link

https://play.vuetifyjs.com/#...

Other comments

Very likely, that custom-filter prop instructions have to be updated and I'm just using custom filter function incorrectly, after "support multiple match highlighting" feature landed in 9da6442

@MatthewAry MatthewAry added the layer 8 issue You're doing it wrong label Apr 8, 2025
@github-actions github-actions bot removed the S: triage label Apr 8, 2025
@MatthewAry
Copy link
Contributor

Hey there. The issue here is not that it's not highlighting all the values with the specific letter but that your filter function is not returning the correct values. Now, an argument could be made that this is a bug, but I believe the purpose of the custom-filter function prop is to allow you to inform the component how to filter on an object or something else. Highlighting is kind of a benefit. I took your code and compared it to the defaultFilter function https://play.vuetifyjs.com/playgrounds/X5pqYg and it seems that highlighting works by providing arrays that represent the range you want to have highlighted in the matched result, if not a match it's a -1. The spec also says that it will accept a boolean as a filter result, but you won't get highlighting with that.

What is your use case here that requires you to have a custom filter function? If you're trying to filter on an object with a custom item slot, you'd have to implement your own variant of highlighting.

@KaelWD
Copy link
Member

KaelWD commented Apr 8, 2025

It is a bug, I did [start, length] instead of [start, end]

@KaelWD KaelWD self-assigned this Apr 8, 2025
@KaelWD KaelWD added T: bug Functionality that does not work as intended/expected and removed layer 8 issue You're doing it wrong labels Apr 8, 2025
@KaelWD KaelWD added this to the v3.8.x milestone Apr 8, 2025
@KaelWD KaelWD closed this as completed in 1bef712 Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VAutocomplete T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

No branches or pull requests

3 participants