mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-26 05:51:17 -07:00
Fix: Make calendar hover event toggle explicit (#6639)
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
@@ -39,8 +39,8 @@ export default function Event({ event, colorVariants, showDate = false, showTime
|
|||||||
return event.url ? (
|
return event.url ? (
|
||||||
<a
|
<a
|
||||||
className={classNames(className, "hover:bg-theme-300/50 dark:hover:bg-theme-800/20")}
|
className={classNames(className, "hover:bg-theme-300/50 dark:hover:bg-theme-800/20")}
|
||||||
onMouseEnter={() => setHover(!hover)}
|
onMouseEnter={() => setHover(true)}
|
||||||
onMouseLeave={() => setHover(!hover)}
|
onMouseLeave={() => setHover(false)}
|
||||||
key={key}
|
key={key}
|
||||||
href={event.url}
|
href={event.url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@@ -49,7 +49,7 @@ export default function Event({ event, colorVariants, showDate = false, showTime
|
|||||||
{children}
|
{children}
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : (
|
||||||
<div className={className} onMouseEnter={() => setHover(!hover)} onMouseLeave={() => setHover(!hover)} key={key}>
|
<div className={className} onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)} key={key}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,6 +48,56 @@ describe("widgets/calendar/event", () => {
|
|||||||
expect(link.querySelector("svg")).toBeTruthy();
|
expect(link.querySelector("svg")).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps additional text visible after repeated mouse enter events", () => {
|
||||||
|
const date = DateTime.fromISO("2099-01-01T13:00:00.000Z").setZone("utc");
|
||||||
|
|
||||||
|
render(
|
||||||
|
<Event
|
||||||
|
event={{
|
||||||
|
title: "Primary",
|
||||||
|
additional: "More info",
|
||||||
|
date,
|
||||||
|
color: "gray",
|
||||||
|
url: "https://example.com",
|
||||||
|
}}
|
||||||
|
colorVariants={{ gray: "bg-gray-500" }}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
const link = screen.getByRole("link", { name: /primary/i });
|
||||||
|
|
||||||
|
fireEvent.mouseEnter(link);
|
||||||
|
fireEvent.mouseEnter(link);
|
||||||
|
expect(screen.getByText("More info")).toBeInTheDocument();
|
||||||
|
expect(screen.queryByText("Primary")).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("keeps title visible after repeated mouse leave events", () => {
|
||||||
|
const date = DateTime.fromISO("2099-01-01T13:00:00.000Z").setZone("utc");
|
||||||
|
|
||||||
|
render(
|
||||||
|
<Event
|
||||||
|
event={{
|
||||||
|
title: "Primary",
|
||||||
|
additional: "More info",
|
||||||
|
date,
|
||||||
|
color: "gray",
|
||||||
|
}}
|
||||||
|
colorVariants={{ gray: "bg-gray-500" }}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
|
||||||
|
const event = screen.getByText("Primary").closest("div.flex");
|
||||||
|
|
||||||
|
fireEvent.mouseEnter(event);
|
||||||
|
expect(screen.getByText("More info")).toBeInTheDocument();
|
||||||
|
|
||||||
|
fireEvent.mouseLeave(event);
|
||||||
|
fireEvent.mouseLeave(event);
|
||||||
|
expect(screen.getByText("Primary")).toBeInTheDocument();
|
||||||
|
expect(screen.queryByText("More info")).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it("compareDateTimezone matches dates by day", () => {
|
it("compareDateTimezone matches dates by day", () => {
|
||||||
const day = DateTime.fromISO("2099-01-01T00:00:00.000Z").setZone("utc");
|
const day = DateTime.fromISO("2099-01-01T00:00:00.000Z").setZone("utc");
|
||||||
expect(compareDateTimezone(day, { date: DateTime.fromISO("2099-01-01T23:59:00.000Z").setZone("utc") })).toBe(true);
|
expect(compareDateTimezone(day, { date: DateTime.fromISO("2099-01-01T23:59:00.000Z").setZone("utc") })).toBe(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user