mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-21 08:16:53 +00:00
Preserve integration category filter on noop keyup (#36844)
This commit is contained in:
parent
ce61d721ff
commit
25715f712f
@ -67,7 +67,7 @@ regenerate: false
|
|||||||
{%- assign category_name = cat -%}
|
{%- assign category_name = cat -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- assign components_count = components_count | plus: 1 -%}
|
{%- assign components_count = components_count | plus: 1 -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
@ -98,7 +98,7 @@ regenerate: false
|
|||||||
{%- assign category_name = cat -%}
|
{%- assign category_name = cat -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- assign components_count = components_count | plus: 1 -%}
|
{%- assign components_count = components_count | plus: 1 -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
@ -208,7 +208,7 @@ allComponents.pop(); // remove placeholder element at the end
|
|||||||
if (hash.indexOf(SEARCH_PREFIX) === 0) {
|
if (hash.indexOf(SEARCH_PREFIX) === 0) {
|
||||||
// search through title and category
|
// search through title and category
|
||||||
search = decodeURIComponent(hash).substring(SEARCH_PREFIX.length).toLowerCase();
|
search = decodeURIComponent(hash).substring(SEARCH_PREFIX.length).toLowerCase();
|
||||||
filter = comp =>
|
filter = comp =>
|
||||||
comp.search.indexOf(search) !== -1 ||
|
comp.search.indexOf(search) !== -1 ||
|
||||||
comp.cat.find((c) => c.includes("#")) != undefined;
|
comp.cat.find((c) => c.includes("#")) != undefined;
|
||||||
|
|
||||||
@ -309,17 +309,19 @@ allComponents.pop(); // remove placeholder element at the end
|
|||||||
};
|
};
|
||||||
|
|
||||||
// update view by search text
|
// update view by search text
|
||||||
|
let lastSearchText = '';
|
||||||
searchInputEl.addEventListener('keyup', debounce(() => {
|
searchInputEl.addEventListener('keyup', debounce(() => {
|
||||||
const text = searchInputEl.value
|
const text = searchInputEl.value
|
||||||
// sanitize input
|
// sanitize input
|
||||||
.replace(/[(\?|\&\{\}\(\))]/gi, '')
|
.replace(/[(\?|\&\{\}\(\))]/gi, '')
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
let newHash = typeof text === "string" && text.length >= 1
|
// Only apply filter if value has changed
|
||||||
? SEARCH_PREFIX + text
|
if (lastSearchText !== text) {
|
||||||
: '#all';
|
lastSearchText = text;
|
||||||
// Only apply filter if hash has changed
|
const newHash = typeof text === "string" && text.length >= 1
|
||||||
if (newHash !== window.location.hash) {
|
? SEARCH_PREFIX + text
|
||||||
|
: '#all';
|
||||||
history.pushState('', '', newHash);
|
history.pushState('', '', newHash);
|
||||||
applyFilter();
|
applyFilter();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user