Files
wekan/models/lib/commentBadgeTitle.js
T
Lauri Ojansivu 67c5df2535 Show a single comment in the minicard badge tooltip
Reuse the existing visible comment data and escaped title attribute. Keep the localized count for multiple or empty comments. Cover count fallback and plain-text handling with Node tests, and verify admin/read-only rendering and private-board comment isolation in Chromium.

Thanks to lonix1 and xet7 !

Fixes #1933,
2026-09-27 14:38:03 +03:00

10 lines
429 B
JavaScript

// Reuse only the comments already visible to the caller. Render the returned
// string through a normal escaped title attribute, never as HTML.
export function commentBadgeTitle(comments, countTitle) {
const visible = Array.isArray(comments) ? comments : [];
if (visible.length === 1 && typeof visible[0]?.text === 'string' && visible[0].text.trim()) {
return visible[0].text;
}
return countTitle(visible.length);
}