fix(widgets): fix hover card disappearing and remove group wrapper

- Remove wrapper div that broke HoverCard hover tracking between
  target and dropdown (root cause of instant disappear)
- Remove useElementSize, always show notification dots
- Increase closeDelay to 400ms (per Mantine interactive-elements
  pattern) so users can move mouse into dropdown with link buttons
- Remove HoverCard.Group from component.tsx per feedback
This commit is contained in:
ajnart committed 2026-07-21 17:58:19 +02:00
1 parent c08054736e
commit 28fefcd23f
2 files changed
+40 -48

No files matched your search

+36 -42
View File
@@ -1,5 +1,4 @@
import { Box, Container, Flex, HoverCard, Text, useMantineTheme } from "@mantine/core"; import { Box, Container, Flex, HoverCard, Text, useMantineTheme } from "@mantine/core";
import { useElementSize } from "@mantine/hooks";
import { useRequiredBoard } from "@homarr/boards/context"; import { useRequiredBoard } from "@homarr/boards/context";
import type { CalendarEvent } from "@homarr/integrations/types"; import type { CalendarEvent } from "@homarr/integrations/types";
@@ -15,7 +14,6 @@ interface CalendarDayProps {
} }
export const CalendarDay = ({ date, events, disabled, rootHeight, rootWidth }: CalendarDayProps) => { export const CalendarDay = ({ date, events, disabled, rootHeight, rootWidth }: CalendarDayProps) => {
const { ref, height } = useElementSize();
const board = useRequiredBoard(); const board = useRequiredBoard();
const mantineTheme = useMantineTheme(); const mantineTheme = useMantineTheme();
const actualItemRadius = mantineTheme.radius[board.itemRadius]; const actualItemRadius = mantineTheme.radius[board.itemRadius];
@@ -24,47 +22,43 @@ export const CalendarDay = ({ date, events, disabled, rootHeight, rootWidth }: C
const shouldScaleDown = minAxisSize < 350; const shouldScaleDown = minAxisSize < 350;
const isSmall = rootHeight < 256; const isSmall = rootHeight < 256;
const isTooSmallForIndicators = height < 30;
return ( return (
<div ref={ref} style={{ width: "100%", height: "100%" }}> <HoverCard
<HoverCard position="bottom"
position="bottom" withArrow
withArrow withinPortal
withinPortal radius="lg"
radius="lg" shadow="sm"
shadow="sm" transitionProps={{ transition: "pop" }}
transitionProps={{ transition: "pop" }} openDelay={350}
openDelay={350} closeDelay={400}
closeDelay={200} disabled={disabled}
disabled={disabled} >
> <HoverCard.Target>
<HoverCard.Target> <Container
<Container h="100%"
h="100%" w="100%"
w="100%" p={0}
p={0} pt={isSmall ? 0 : 10}
pt={isSmall ? 0 : 10} pb={isSmall ? 0 : 10}
pb={isSmall ? 0 : 10} m={0}
m={0} pos="relative"
pos="relative" style={{
style={{ alignContent: "center",
alignContent: "center", borderRadius: actualItemRadius,
borderRadius: actualItemRadius, cursor: disabled ? "default" : "pointer",
cursor: disabled ? "default" : "pointer", }}
}} >
> <Text ta={"center"} size={shouldScaleDown ? "xs" : "md"} lh={1}>
<Text ta={"center"} size={shouldScaleDown ? "xs" : "md"} lh={1}> {date.getDate()}
{date.getDate()} </Text>
</Text> <NotificationIndicator events={events} isSmall={isSmall} />
{!isTooSmallForIndicators && <NotificationIndicator events={events} isSmall={isSmall} />} </Container>
</Container> </HoverCard.Target>
</HoverCard.Target> <HoverCard.Dropdown maw="calc(100vw - 24px)" w={512} pe={4} pb={0} style={{ overflow: "hidden" }}>
<HoverCard.Dropdown maw="calc(100vw - 24px)" w={512} pe={4} pb={0} style={{ overflow: "hidden" }}> <CalendarEventList events={events} />
<CalendarEventList events={events} /> </HoverCard.Dropdown>
</HoverCard.Dropdown> </HoverCard>
</HoverCard>
</div>
); );
}; };
+4 -6
View File
@@ -2,7 +2,7 @@
import { useMemo, useState } from "react"; import { useMemo, useState } from "react";
import { useParams } from "next/navigation"; import { useParams } from "next/navigation";
import { useMantineTheme, HoverCard } from "@mantine/core"; import { useMantineTheme } from "@mantine/core";
import { Calendar } from "@mantine/dates"; import { Calendar } from "@mantine/dates";
import { useElementSize } from "@mantine/hooks"; import { useElementSize } from "@mantine/hooks";
import dayjs from "dayjs"; import dayjs from "dayjs";
@@ -67,9 +67,8 @@ const CalendarBase = ({ isEditMode, events, month, setMonth, options }: Calendar
const normalizedEvents = useMemo(() => splitEvents(events), [events]); const normalizedEvents = useMemo(() => splitEvents(events), [events]);
return ( return (
<HoverCard.Group openDelay={350} closeDelay={200}> <Calendar
<Calendar defaultDate={new Date()}
defaultDate={new Date()}
onPreviousMonth={(month) => setMonth(new Date(month))} onPreviousMonth={(month) => setMonth(new Date(month))}
onNextMonth={(month) => setMonth(new Date(month))} onNextMonth={(month) => setMonth(new Date(month))}
highlightToday highlightToday
@@ -145,8 +144,7 @@ const CalendarBase = ({ isEditMode, events, month, setMonth, options }: Calendar
/> />
); );
}} }}
/> />
</HoverCard.Group>
); );
}; };