question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug Report] VAutocomplete is filtering out non text item

See original GitHub issue

Environment

Vuetify Version: 2.3.0-beta.6 Last working version: 2.2.28 Vue Version: 2.6.11 Browsers: Firefox 76.0 OS: Linux x86_64

Steps to reproduce

My VAutocomplete instance contains object items. By using filter function as stated in the documentation, it receives item: object, so I can filter the object with my own rules, and return either true or false.

Expected Behavior

When filter function returns true for an item, it must be shown.

Actual Behavior

It is filtered out by f8068ed6d4905c953463cf898150aae0b940fc3e for no explicit reason.

Reproduction Link

https://codepen.io/glandos/pen/LYpMdGO

Other comments

Maybe update the documentation to requires that getText must return a value? But I see no reason to remove items if the user wants to filter it manually.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
johnleidercommented, Jun 3, 2020

The dividers and headers were never shown when searching; I’m not sure how this affects the layout. Both my fix and the proposal in #11442 made assumptions on what the user would want. #11442 checks to see if the object is specifically divider or header while f8068ed says if there isn’t a text value to display, there is no point in sending back the result.

With that being said, I agree that the items should pass to the filter regardless. This is what I’m planning on implementing as a fix that keeps #11415 resolved as well as resolving this one.

{
  filteredItems (): object[] {
    if (!this.isSearching || this.noFilter || this.internalSearch == null) return this.allItems

    return this.allItems.filter(item => {
      const value = getPropertyFromItem(item, this.itemText, undefined)
      const text = value ? String(value) : ''

      return this.filter(item, String(this.internalSearch), text)
    })
  }
}
0reactions
Glandoscommented, Jun 5, 2020

Your correction is OK for me, many thanks for that!

I have to admit that I was in a hurry when submitting the bug, and I didn’t really explain why I needed this. I am using VAutocomplete in an unusual way that can display multiple elements depending on what’s typed, and separate elements by dividers if needed. This is like a search box with different sources and different result types. So I still need header and dividers after filtering, based on my custom filter function.

Read more comments on GitHub >

github_iconTop Results From Across the Web

wrong highlighting of matched text when using custom filter ...
[Bug Report] v-select with autocomplete - wrong highlighting of matched text when using ... The filtered items are highlighter correctly.
Read more >
Issues for Views Autocomplete Filters | Drupal.org
Title Status Prior... Autocomplete field search results incorrect width Needs review Nor... The search text after the slash is missed Needs review Nor... Not working with...
Read more >
Filter Autocomplete suggestions does not work - Bug reports
The filter does still work if you enter in a valid filter... The fields are Category and set to Search Box in the...
Read more >
autocomplete search filter not showing on second item set on ...
1) run app click 'swap search' and the 'text'; is set and shows the filtered items and click an item to set. 2)...
Read more >
Why AutoComplete does not filter using text field - Syncfusion
To filter items in AutoComplete based on both text and value fields, use predicate of dataManager using the filtering event. The filtered data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found