Skip to content

fix(calendar): default new task to the last-activated board#991

Merged
renemadsen merged 1 commit into
stablefrom
fix/calendar-default-board-last-activated
Jun 9, 2026
Merged

fix(calendar): default new task to the last-activated board#991
renemadsen merged 1 commit into
stablefrom
fix/calendar-default-board-last-activated

Conversation

@renemadsen

Copy link
Copy Markdown
Member

What

Fixes a user-reported bug: when creating a calendar task, the board ("tavle") dropdown defaulted to the first-created board ("Miljøtilsyn") instead of the board the user had just marked active.

Root cause

There is no persistent "active/default board" concept — the sidebar checkbox toggles a transient in-memory visibility filter (activeBoardIds). The modal only honoured it when exactly one board was checked; with more than one active (the common case: the auto-selected default board stays checked when the user activates a new one), it fell back to the lowest-id board.

Fix

Track the most-recently-activated board in memory:

  • onBoardToggled records the board when the user turns it on.
  • loadBoards seeds it to the auto-selected board on load / property switch.
  • openCreateModal passes it to the modal while it's still active; otherwise the existing fallback is preserved.

No DB/API/migration. The modal's own find(...) ?? fallbackBoard already guards a stale/deleted id.

Tests

New Playwright e2e n/calendar-default-board.spec.ts (3 serial tests): modal defaults to the last-activated board even when several stay checked; falls back (not the deactivated board) otherwise. All pass locally. Added id="calendarEventBoard" to the board select as the test hook.

Design spec: docs/superpowers/specs/2026-06-09-calendar-new-task-default-board-design.md.

🤖 Generated with Claude Code

The create-task modal pre-selected the lowest-id board (the first-created
board, e.g. "Miljøtilsyn") whenever more than one board was active in the
sidebar, ignoring the board the user had just marked active. The sidebar
"active" state is a transient multi-select visibility filter with no persisted
default-board concept, and the modal only honoured it when exactly one board
was checked.

Track the most-recently-activated board in memory: set it when the user turns
a board ON in the sidebar (and seed it to the auto-selected board on load), and
default the create-task modal to it while it stays active. Falls back to the
existing behaviour when that board is no longer active. No DB/API change.

Adds a Playwright e2e (n/calendar-default-board.spec.ts) covering the default
and the fallback, and an id on the board select for the test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 9, 2026 05:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the calendar create-task flow so the board (“tavle”) dropdown defaults to the most recently activated board (instead of falling back to the lowest-id board when multiple boards are active). This is implemented entirely in the Angular frontend with an accompanying Playwright regression test.

Changes:

  • Track lastActivatedBoardId in CalendarContainerComponent and prefer it when opening the create-task modal (when it’s still active).
  • Add a stable DOM hook (id="calendarEventBoard") to the board select in the task create/edit modal.
  • Add a new Playwright serial e2e suite covering “last-activated board” defaulting and the fallback when that board is later deactivated.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
eform-client/src/app/plugins/modules/backend-configuration-pn/modules/calendar/modals/task-create-edit-modal/task-create-edit-modal.component.html Adds a stable selector id for the board dropdown to support e2e assertions.
eform-client/src/app/plugins/modules/backend-configuration-pn/modules/calendar/components/calendar-container/calendar-container.component.ts Introduces lastActivatedBoardId and uses it to choose the modal’s default board selection.
eform-client/playwright/e2e/plugins/backend-configuration-pn/n/calendar-default-board.spec.ts Adds regression coverage ensuring the modal defaults to the last-activated board and falls back correctly when it’s deactivated.

Comment on lines +477 to +479
// The store update is async, so activeBoardIds here still reflects the
// pre-toggle state: if the board is not currently active, this click is
// turning it ON — remember it as the default for new tasks.
Comment on lines +25 to +26
async function createBoard(page: import('@playwright/test').Page, name: string) {
await page.locator('a.sidebar-action-link', { hasText: 'Opret tavle' }).click();
expect(label.length).toBeGreaterThan(0);
expect(label).not.toBe(boardB);
});
});
@renemadsen renemadsen merged commit 05645b6 into stable Jun 9, 2026
51 of 52 checks passed
@renemadsen renemadsen deleted the fix/calendar-default-board-last-activated branch June 9, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants