Haroenv/holmes

Question about clearing search field.

BlakeHoward opened this issue · 3 comments

Hello,

I read previous issues and couldn't find an answer to my exact question. I apologize if I overlooked a sufficient answer. My question is how, when clearing the searching field using an "X" like in the demo(s) provided, can all of the searchable divs/elements return to the page? For me, currently, if I were to search a string that did not exist in any searchable div, the placeholder would appear is should "e.g., "No results found." However, unlike the demos, when I clear the field with the "X," the place holder remains and no divs return. It is only when I begin to type again that the elements reappear. It may also be beneficial to note that backspacing after the placeholder appears works as expected, i.e., the elements reappear if the new shortened String is found in any div. Let me know if you have any suggestions or methods to solve this.

Thank you!

I've had someone describe this issue on the gitter channel as well. The reason is because I watch for input events, setting the text to '' doesn't cause such an event. In there I posted a codepen link that adds an event to a certain reset button (currently on mobile so it's hard to link it).

I will however take this feedback in account and a clear function to Holmes would be beneficial. I'll consider writing this, and pull requests are welcome too.

It shouldn't be too hard to add, but it would be the first non-initialising function Holmes gets, so just a slight thinking exercise.

Codepen: http://codepen.io/Haroenv/pen/wWmkok

Awesome, your example worked perfectly. Yeah, that makes sense that simply setting the text to any empty string wouldn't create the necessary event. I agree that a native clear function would be nice. Thanks for your support.

I'll close this issue since there is a workaround, but I made a separate issue for the .clear() function.