darrenjennings / vue-autosuggest

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

[feature request] Give autosuggest__results-container a class when the list is empty #98

Closed wujekbogdan closed 5 years ago

wujekbogdan commented 5 years ago

Could you give the .autosuggest__results-container a class when the array of suggestions is empty? It could be for example autosuggest__results-container--empty.

darrenjennings commented 5 years ago

Are there any aria attributes or anything that could yield this without having to toggle a class? I'm not against it, just wondering if class is the right attribute.

wujekbogdan commented 5 years ago

Are there any aria attributes or anything that could yield this without having to toggle a class?

Probably aria-hidden="true" is the right one.

I'm not against it, just wondering if class is the right attribute.

It's perfectly valid to use a class with a modifier if we are to implement BEM-compatible classes https://github.com/darrenjennings/vue-autosuggest/issues/96

BEM methodology discourages from styling elements based on attributes. Of course, the aria- attribute is also valid but it should not be used for styling. It has a different purpose.

darrenjennings commented 5 years ago

Leaning on just requiring this in user land since the "no results" is the same as suggestions.length === 0 which would allow users to easily toggle a class on the component when there are no suggestions.