Skip to content

Commit

Permalink
fix: ignore case by default
Browse files Browse the repository at this point in the history
Fix #157
  • Loading branch information
Ernest committed Apr 3, 2021
1 parent 3c46d53 commit 0132082
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cypress/integration/props/searchable/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ context('searchable', () => {
cy.get('.vue-input').type('Rails')
cy.get('.vue-dropdown-item').should('have.length', 1)
})

it('filter typing value (ignore case) by label by default', () => {
cy.visit(path.join(__dirname, 'default.html'))
cy.get('.vue-select').click()

cy.get('.vue-input').type('RAILS')
cy.get('.vue-dropdown-item').should('have.length', 1)
})
})
3 changes: 2 additions & 1 deletion src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,10 @@ const VueSelect = {
const handleBlurForInput = event => {
blur()
}
const searchRe = computed(() => new RegExp(searchingInputValue.value, 'i'))
const searchedOptions = computed(() => {
return searchingInputValue.value
? options.value.filter(option => (labelBy.value(option) + '').indexOf(searchingInputValue.value) > -1)
? options.value.filter(option => searchRe.value.test(labelBy.value(option)))
: undefined
})
Expand Down

0 comments on commit 0132082

Please sign in to comment.