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

Can't use special characters with typeahead #50

Closed
adrianlungu opened this issue Jul 29, 2017 · 2 comments
Closed

Can't use special characters with typeahead #50

adrianlungu opened this issue Jul 29, 2017 · 2 comments
Labels

Comments

@adrianlungu
Copy link
Contributor

OS, browser, uiv version

Mac OS X 10.12.5, Chrome 60, uiv 0.11.6

Which component

Typeahead

Steps to reproduce the problem

Use a special character (*, ?) in the typeahead input

Expected behavior

Show strings that start with or contain the characters

Actual behavior

[Vue warn]: Error in render function: "SyntaxError: Invalid regular expression: /*/: Nothing to repeat"
found in
---> <Typeahead>
@adrianlungu adrianlungu changed the title Can't use special character with typeahead Can't use special characters with typeahead Jul 29, 2017
@adrianlungu
Copy link
Contributor Author

I've currently fixed it in a fork by modifying the Highlight function in Typeahead.vue to:

highlight (item) {
        let value = this.itemKey ? item[this.itemKey] : item
        let inputValue = this.inputEl.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
        return value.replace(new RegExp(`${inputValue}`, this.regexOptions), '<b>$&</b>')
      }

@wxsms
Copy link
Member

wxsms commented Jul 31, 2017

hi, sry for the late.

Thanks for your solution, if it works as expect, it's welcome to PR this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants