Files
wekan/models/lib/boardLayoutMount.js
T
Lauri Ojansivu 4387185002 Large board: open and close a card by its address without re-creating the board.
The card and board routes rendered the board layout on every navigation, and
flow-router-extra re-creates the layout each time: every swimlane, list and
minicard was torn down and built again for a card link, the up/down card
keys, back/forward, and closing a card opened from a link. The router now
remembers which board the layout is mounted for (models/lib/boardLayoutMount.js)
and the card and board routes reuse it; the board already follows Session.
Another board, a first load and the list/swimlane routes still render.

tests/playwright/specs/large-board-card-open.e2e.js checks in Chromium,
Firefox and WebKit that a minicard element survives a card opened and closed
by its address, and counts the Tracker work of a click open and close.

Thanks to markusst1982 and xet7 !

Fixes #6745.
2026-10-07 03:08:48 +03:00

35 lines
1.7 KiB
JavaScript

'use strict';
// #6745: opening or closing a card by its address re-created the whole board.
// The card route and the board route both called
// this.render('defaultLayout', { content: 'board' }), and flow-router-extra
// treats an object as new data and re-renders the layout every time - every
// swimlane, list and minicard torn down and built again, and in lazy loading
// every list's card window re-subscribed. Card links, the up/down card keys,
// back/forward and closing a card opened from a link all went through it.
//
// The board template already follows Session (currentCard, openCards) by
// itself, so when the board on screen IS the board of the new address, the
// route only has to set Session. Pure, so tests/largeBoardCardOpen.test.cjs
// runs it without Meteor.
// Routes that render the board layout. Entering any other route replaces the
// layout, so nothing is mounted any more.
const BOARD_LAYOUT_ROUTES = ['board', 'board-short', 'card', 'list', 'swimlane'];
// Of those, the ones that may reuse a mounted board. The list and swimlane
// routes still render, as they always have.
const REUSING_ROUTES = ['board', 'card'];
// What stays mounted once `routeName` is entered.
function mountedBoardAfterEnter(mountedBoardId, routeName) {
return BOARD_LAYOUT_ROUTES.includes(routeName) ? mountedBoardId || null : null;
}
// Must `routeName` for `boardId` render the board layout?
function mustRenderBoardLayout(mountedBoardId, boardId, routeName) {
if (!boardId || !mountedBoardId) return true;
if (!REUSING_ROUTES.includes(routeName)) return true;
return mountedBoardId !== boardId;
}
module.exports = { BOARD_LAYOUT_ROUTES, REUSING_ROUTES, mountedBoardAfterEnter, mustRenderBoardLayout };