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

View File

@ -91,6 +91,18 @@
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
async function toggleDropdown() {
isOpen = !isOpen;
@ -273,6 +285,8 @@
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke
Politeness="round"
stroke-width="2"
d="M19 9l-7 7-7-7"
/>