diff --git a/docs/releases/unreleased.md b/docs/releases/unreleased.md index 289f95b5d..a423f1c04 100644 --- a/docs/releases/unreleased.md +++ b/docs/releases/unreleased.md @@ -43,6 +43,8 @@ When a change has user-facing documentation, include a canonical tasknotes.dev l - (#2606) Fixed Ctrl/Cmd-click on a task in Task List, Kanban, Calendar and Agenda views selecting the task instead of opening its note in a new tab. Ctrl/Cmd-click and middle-click now open the note in a new tab on every task card, calendar event and task link in a note, as links do in Obsidian; Ctrl/Cmd+Alt-click opens it to the side. To select several tasks, Shift-click a task first; while a selection is active, Ctrl/Cmd-click adds or removes tasks as before. The task menu again has **Open note in new tab** next to **Open note**, instead of only under **Note actions**. See [Task List view](https://tasknotes.dev/views/task-list/#task-actions). - Thanks to @minchinweb for reporting +- (#2641) Fixed tasks in the calendar's Month view not moving when dragged while the calendar is 850px wide or narrower. At that width Month shows tasks as compact chips, and dragging one selected days and opened the create menu instead. The chips can now be dragged to another day, clicked to open the task and right-clicked for the task menu, as in the wider layout. With **Show selected day panel** on, pressing a chip still selects its day. + - Thanks to @jvvehh-arch for reporting - (#2618) Fixed the "About default `.base` files" note at the end of the release notes pointing to a General settings page that no longer exists. It now points to **Settings → TaskNotes → Appearance & interaction → Views & base files → Update files** and mentions the **TaskNotes: Update default base files** command. - Thanks to @Alireza-RS for reporting - (#2579) Fixed task links in notes taking extra space on phones in Live Preview. A task link on a checkbox line (`- [ ] [[Task]]`) took three lines (checkbox, task, then the convert button) and now stays on one row, level with the checkbox. When no status or priority is shown, the title no longer starts after an empty gap. diff --git a/e2e/issues/issue-2641-month-view-drag.spec.ts b/e2e/issues/issue-2641-month-view-drag.spec.ts new file mode 100644 index 000000000..95b31b758 --- /dev/null +++ b/e2e/issues/issue-2641-month-view-drag.spec.ts @@ -0,0 +1,97 @@ +/** + * Issue #2641: in the calendar's Month view, dragging a task started a date + * selection (and opened the create menu) instead of moving the task. At + * calendar widths up to 850px Month draws tasks as compact chips, which ignored + * the pointer, so the press reached the day cell underneath. + * + * @see https://github.com/callumalpass/tasknotes/issues/2641 + */ +import { test, expect, type Page } from '@playwright/test'; +import { launchObsidian, closeObsidian, setObsidianViewport } from '../obsidian'; + +const BASE = 'TaskNotes/Views/issue-2641.base'; +const TASKS = [ + { path: 'TaskNotes/Issue 2641 all day.md', title: 'Issue 2641 all day', time: '' }, + { path: 'TaskNotes/Issue 2641 timed.md', title: 'Issue 2641 timed', time: 'T09:00' }, +]; + +const ymd = (d: Date) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`; + +async function readScheduled(page: Page, path: string): Promise { + return page.evaluate(async (p) => { + const w = window as any; + const text: string = await w.app.vault.read(w.app.vault.getAbstractFileByPath(p)); + return text.match(/^scheduled:\s*(.+)$/m)?.[1]?.trim().replace(/^["']|["']$/g, ''); + }, path); +} + +test('month view drags move tasks instead of selecting days', async ({}, testInfo) => { + const app = await launchObsidian(); + const page = app.page; + await setObsidianViewport(page, { width: 1150, height: 900 }); + const now = new Date(); + const from = new Date(now.getFullYear(), now.getMonth(), 15); + const to = new Date(now.getFullYear(), now.getMonth(), 16); + try { + await page.evaluate(async ({ tasks, base, day }) => { + const w = window as any; + for (const task of tasks) { + const text = `---\ntitle: ${task.title}\nstatus: open\nscheduled: ${day}${task.time}\ntags:\n - task\n---\n`; + const existing = w.app.vault.getAbstractFileByPath(task.path); + if (existing) await w.app.vault.modify(existing, text); + else await w.app.vault.create(task.path, text); + } + // The reporter's view: a stale `calendarView` inside `options` and the real one at the top level. + const baseText = [ + 'filters:', + ' and:', + ' - file.name.startsWith("Issue 2641")', + 'views:', + ' - type: tasknotesCalendar', + ' name: Calendar', + ' options:', + ' showScheduled: true', + ' showDue: true', + ' calendarView: timeGridWeek', + ' calendarView: dayGridMonth', + '', + ].join('\n'); + const existing = w.app.vault.getAbstractFileByPath(base); + if (existing) await w.app.vault.modify(existing, baseText); + else await w.app.vault.create(base, baseText); + await w.app.workspace.getLeaf('tab').openFile(w.app.vault.getAbstractFileByPath(base)); + }, { tasks: TASKS, base: BASE, day: ymd(from) }); + + const root = page.locator('.tnc:visible').first(); + // Narrow enough for the compact chip layout the reporter saw. + await expect(root.locator('.tnc-dg.tnc-dg--chips')).toBeVisible(); + + for (const task of TASKS) { + const item = root.locator('.tnc-item', { hasText: task.title }).first(); + await expect(item).toBeVisible(); + const box = (await item.boundingBox())!; + const target = (await root.locator(`.tnc-dg-day[data-date="${ymd(to)}"]`).boundingBox())!; + await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2); + await page.mouse.down(); + await page.mouse.move(target.x + target.width / 2, target.y + target.height / 2, { steps: 15 }); + await page.screenshot({ path: testInfo.outputPath(`${task.time ? 'timed' : 'allday'}-dragging.png`) }); + expect(await root.evaluate(el => el.classList.contains('tnc-dragging-select') || !!el.querySelector('.tnc-sel'))).toBe(false); + await page.mouse.up(); + await expect(page.locator('.menu')).toHaveCount(0); + await expect.poll(() => readScheduled(page, task.path)).toBe(`${ymd(to)}${task.time}`); + } + } finally { + try { + await page.keyboard.press('Escape'); + await page.evaluate(async ({ tasks, base }) => { + const w = window as any; + for (const p of [base, ...tasks.map((t: { path: string }) => t.path)]) { + const f = w.app.vault.getAbstractFileByPath(p); + if (f) await w.app.vault.delete(f); + } + }, { tasks: TASKS, base: BASE }); + } finally { + await closeObsidian(app); + } + } +}); diff --git a/styles/bases-calendar.css b/styles/bases-calendar.css index 015a530ce..9b9dbe089 100644 --- a/styles/bases-calendar.css +++ b/styles/bases-calendar.css @@ -1580,6 +1580,12 @@ body.is-mobile.tn-calendar-has-selection .tn-toast { cursor: var(--cursor-link, pointer); } +/* Without the day panel, chips are the tasks themselves: click, drag and right-click them (#2641). */ +.tasknotes-plugin #bases-calendar:not(.tn-calendar-composition) .tnc-dg--chips .tnc-dg-dots > .tnc-item--indicator { + pointer-events: auto; + cursor: var(--cursor-link, pointer); +} + .tasknotes-plugin #bases-calendar:not(.tn-calendar-composition) .tnc-dg-dots-more:focus-visible { outline: 2px solid var(--tn-focus-ring); outline-offset: -2px;