Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar preview shows correct files for each dot #2401

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion src/ui/views/calendar-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,26 @@ export class DataviewCalendarRenderer extends DataviewRefreshableRenderer {
return;
}

renderer.app.workspace.trigger("link-hover", {}, targetEl, vals[0].link.path, vals[0].link.path);
let dayEl: Element = targetEl as Element;
while (!dayEl.classList.contains("day")) dayEl = dayEl.parentElement!;

for (const [i, dot] of [...dayEl.children[0].children].entries()) {
dot.setAttribute("data-dot-idx", i + "");
}

let dotEl: Element = targetEl as Element;
if (dotEl.tagName.toLowerCase() === "div") return; // No dot hovered.
if (dotEl.tagName.toLowerCase() === "circle") dotEl = dotEl.parentElement!;

const dotIdx = parseInt(dotEl.getAttribute("data-dot-idx")!);

renderer.app.workspace.trigger(
"link-hover",
{},
targetEl,
vals[dotIdx].link.path,
vals[dotIdx].link.path
);
},
onClickDay: async date => {
const vals = dateMap.get(date.format("YYYYMMDD"));
Expand Down