mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-14 21:06:50 +00:00
fix search problem - only if input is not empty change to search hash location (#9434)
This commit is contained in:
parent
06e7c7f8f1
commit
9e654ff3c6
@ -61,7 +61,7 @@ Support for these components is provided by the Home Assistant community.
|
||||
<div class="grid__item five-sixths lap-one-whole palm-one-whole">
|
||||
<div class="component-search">
|
||||
<form onsubmit="event.preventDefault(); return false">
|
||||
<input type="text" name="search" id="search" class="search" placeholder="Search components...">
|
||||
<input type="text" name="search" id="search" class="search" placeholder="Search components..." autofocus />
|
||||
</form>
|
||||
</div>
|
||||
<div class="hass-option-cards" id="componentContainer"> </div>
|
||||
@ -265,9 +265,11 @@ allComponents.pop(); // remove placeholder element at the end
|
||||
$('.component-search input').keyup(debounce(function() {
|
||||
var text = $(this).val();
|
||||
// sanitize input
|
||||
text = text.replace(/[(\?|\&\{\}\(\))]/gi, '');
|
||||
updateHash('#search/' + text);
|
||||
applyFilter();
|
||||
text = text.replace(/[(\?|\&\{\}\(\))]/gi, '').trim();
|
||||
if (typeof text === "string" && text.length !== 0) {
|
||||
updateHash('#search/' + text);
|
||||
applyFilter();
|
||||
}
|
||||
}, 500));
|
||||
|
||||
window.addEventListener('hashchange', applyFilter);
|
||||
|
Loading…
x
Reference in New Issue
Block a user