Skip to content

Commit

Permalink
Directly use debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
ShouvikGhosh2048 committed Apr 5, 2024
1 parent c6801ec commit 9eea898
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/components/mods/modDownloadButton/modDownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ const useStyles = createStyles(
const ModDownloadButton = ({ gamebananaModId }: ModDownloadButtonProps) => {
const { downloadUrl } = useGamebananaModDownloadUrl({ gamebananaModId });
const [opened, { close, open }] = useDisclosure(false);
// Since there is a gap between the link and the popover,
// debouncing prevents the popover from closing when we move from the link to popover.
const [debouncedOpened] = useDebouncedValue(opened, 100);
// We use this so that the popover opens instantly, but takes some time to close.
// Since there is a gap between the link and the popover it prevents the popover from closing
// when we move from the link to popover.
const openPopover = opened || debouncedOpened;

const { classes } = useStyles();

Expand All @@ -51,7 +49,7 @@ const ModDownloadButton = ({ gamebananaModId }: ModDownloadButtonProps) => {
<Popover position="bottom"
withArrow
shadow="md"
opened={openPopover}
opened={debouncedOpened}
classNames={{ dropdown: classes.dropdown, arrow: classes.arrow }}>
<Popover.Target>
<a href={downloadUrl /*TODO!: implement useGamebananaModDownloadUrl */}
Expand Down

0 comments on commit 9eea898

Please sign in to comment.