Skip to content

Commit

Permalink
web/SupportedServices: speed up the secondary expand by ~200μs
Browse files Browse the repository at this point in the history
  • Loading branch information
wukko committed Dec 15, 2024
1 parent 2e4b76d commit 4cdbb02
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions web/src/components/save/SupportedServices.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,26 @@
}
};
const popoverAction = async () => {
expanded = !expanded;
if (expanded && services.length === 0) {
await loadInfo();
}
if (expanded) {
popover.focus();
}
}
const showPopover = async () => {
const timeout = renderPopover ? 0 : 10;
const timeout = !renderPopover;
renderPopover = true;
// 10ms delay to let the popover render for the first time
setTimeout(async () => {
expanded = !expanded;
if (expanded && services.length === 0) {
await loadInfo();
}
if (expanded) {
popover.focus();
}
}, timeout);
if (timeout) {
setTimeout(popoverAction, 10);
} else {
await popoverAction();
}
};
</script>

Expand Down

0 comments on commit 4cdbb02

Please sign in to comment.