This commit is contained in:
Philipp Dormann 2025-05-20 01:35:19 +02:00
parent a00af08b3f
commit 3709881176
Signed by: philipp
GPG Key ID: 3BB9ADD52DCA4314
2 changed files with 31 additions and 4 deletions

View File

@ -73,16 +73,27 @@
); );
}; };
let selectRef;
// function resetComponent() {
// if (selectRef) {
// selectRef.reset();
// console.log("Component state reset");
// }
// }
function resetAll() { function resetAll() {
runnerinfo = { id: 0, firstname: "", lastname: "" }; runnerinfo = { id: 0, firstname: "", lastname: "" };
donorinfo = { id: 0, firstname: "", lastname: "" }; donorinfo = { id: 0, firstname: "", lastname: "" };
amount = 0; amount = 0;
address_checked = false; address_checked = false;
donor_create_new = false; donor_create_new = false;
const clears = document.querySelectorAll(".clearSelect"); // const clears = document.querySelectorAll(".clearSelect");
clears.forEach((c) => { // clears.forEach((c) => {
c.click(); // c.click();
}); // });
// resetComponent();
selectRef.reset();
document.querySelector("#jjqzqicxujrnnh1x3447x18x").focus();
} }
</script> </script>
@ -105,6 +116,8 @@
<!-- --> <!-- -->
<h4 class="text-xl font-semibold">{$_("runner")}</h4> <h4 class="text-xl font-semibold">{$_("runner")}</h4>
<VirtualSelect <VirtualSelect
inputElementID="jjqzqicxujrnnh1x3447x18x"
bind:this={selectRef}
autofocus={true} autofocus={true}
on:onClear={() => { on:onClear={() => {
console.log("Cleared selection"); console.log("Cleared selection");

View File

@ -91,6 +91,18 @@
dispatch("onClear"); dispatch("onClear");
} }
// Reset component state
export function reset() {
selected = null;
searchTerm = "";
isOpen = false;
focusedIndex = -1;
startIndex = 0;
updateVisibleItems();
dispatch("onSelected", null);
dispatch("onClear");
}
// Toggle dropdown // Toggle dropdown
async function toggleDropdown() { async function toggleDropdown() {
isOpen = !isOpen; isOpen = !isOpen;
@ -273,6 +285,8 @@
<path <path
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
stroke
Politeness="round"
stroke-width="2" stroke-width="2"
d="M19 9l-7 7-7-7" d="M19 9l-7 7-7-7"
/> />