darrenjennings / vue-autosuggest

🔍 Vue autosuggest component.
https://darrenjennings.github.io/vue-autosuggest
MIT License
621 stars 91 forks source link

Make Highlight Class Configurable. #188

Open vivekitis opened 4 years ago

vivekitis commented 4 years ago

What: Added prop to set custom class for highlighted item. if prop is set then it will override default highlighted class.

Why: Wanted it as a feature. Ability to set custom class as highlighted class. could have used "componentAttrPrefix" but there are cases, like in module based vue styles were class names have random suffix. and cannot be predetermined, but need to be passed dynamically. Will not break existing functionality.

How: Added new prop 'component-attr-class-autosuggest-item-highlight'. During section rendering, this prop is transformed to highlightClass and passed to sectionConfig, since highlight class logic was hardcoded in section. Did not use section config to pass this prop because even though internally it is being passed through section config for design reasons, but for the user it is a global config. Please ignore formatting changes.. there are only 2 logical changes. one is function 'computedSections' in Autocomplete.vue and one is render function in the file DefaultSection.js.

Checklist:

I had some issue regarding the code in function 'setCurrentIndex'. I've added comments. please inform if i'm mistaken. Failing test case was working through storybook but failing in test case, so i'm a bit confused as to why.

vivekitis commented 4 years ago

Added Test