Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/app/components/dashboard/ItemRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export default function ItemRow(props: ItemRowProps) {
return created !== "" && updated !== "" && created !== updated;
});

const compactDateTooltip = createMemo(() => {
if (shouldShowUpdated()) {
return `${staticDateInfo().updatedTitle}\n${staticDateInfo().createdTitle}`;
}
return staticDateInfo().createdTitle;
});

const compactLabelTooltip = createMemo(() => {
const parts: string[] = [];
if (props.labels.length > 0) {
Expand Down Expand Up @@ -172,9 +179,11 @@ export default function ItemRow(props: ItemRowProps) {
<span class="shrink-0 text-xs text-base-content/50 whitespace-nowrap">
{props.author}
{" · "}
<time datetime={props.updatedAt} title={staticDateInfo().updatedTitle} aria-label={dateDisplay().updatedLabel}>
{dateDisplay().updated || dateDisplay().created}
</time>
<Tooltip content={compactDateTooltip()} contentClass="whitespace-pre-line" class="relative z-10">
<time datetime={props.updatedAt} aria-label={dateDisplay().updatedLabel}>
{dateDisplay().updated || dateDisplay().created}
</time>
</Tooltip>
</span>

</Show>
Expand Down
22 changes: 22 additions & 0 deletions tests/components/ItemRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ describe("ItemRow", () => {
const timeEls = container.querySelectorAll("time");
expect(timeEls.length).toBe(1);
});

it("shows both updated and created dates in tooltip on hover", () => {
vi.useFakeTimers();
const { container, unmount } = render(() => <ItemRow {...defaultProps} />);
const updatedTrigger = container.querySelector(
`time[datetime="${defaultProps.updatedAt}"]`
)?.closest("span.inline-flex");
expect(updatedTrigger).not.toBeNull();
expect(updatedTrigger!.className).toContain("z-10");
fireEvent.pointerEnter(updatedTrigger!);
vi.advanceTimersByTime(300);
expect(document.body.textContent).toContain(
`Updated: ${new Date(defaultProps.updatedAt).toLocaleString()}`
);
expect(document.body.textContent).toContain(
`Created: ${new Date(defaultProps.createdAt).toLocaleString()}`
);
fireEvent.pointerLeave(updatedTrigger!);
vi.advanceTimersByTime(500);
unmount();
vi.useRealTimers();
});
});

it("renders no labels section when labels array is empty", () => {
Expand Down