reimplement click_only_result option, scroll results into view
This commit is contained in:
parent
f94bb702bc
commit
31416870d1
@ -36,7 +36,17 @@ onMount(() => {
|
|||||||
scrollers.filter(item => !scrollers_with_results.includes(item)).forEach( scroller => {
|
scrollers.filter(item => !scrollers_with_results.includes(item)).forEach( scroller => {
|
||||||
scroller.parentNode.style.display= 'none'
|
scroller.parentNode.style.display= 'none'
|
||||||
})
|
})
|
||||||
|
scroll
|
||||||
|
// if only one result and click_only_result is true, click it
|
||||||
|
if(click_only_result && scrollers_with_results.length == 1 && scrollers_with_results[0].querySelector(".matched-recipe").length == 1){
|
||||||
|
scrollers_with_results[0].querySelector(".matched-recipe").click()
|
||||||
}
|
}
|
||||||
|
// if scrollers with results are presenet scroll first result into view
|
||||||
|
if(scrollers_with_results.length > 0){
|
||||||
|
scrollers_with_results[0].scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
search.addEventListener("input", () => {
|
search.addEventListener("input", () => {
|
||||||
do_search();
|
do_search();
|
||||||
@ -60,12 +70,11 @@ onMount(() => {
|
|||||||
if(pair[0] == 'q'){
|
if(pair[0] == 'q'){
|
||||||
const search = document.getElementById("search");
|
const search = document.getElementById("search");
|
||||||
search.value=pair[1];
|
search.value=pair[1];
|
||||||
do_search(click_only_result=true);
|
do_search(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// @license-end
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
input#search {
|
input#search {
|
||||||
|
Loading…
Reference in New Issue
Block a user