diff --git a/reaction_board/web/static/components.js b/reaction_board/web/static/components.js index 2b28ee0..0b33ea8 100644 --- a/reaction_board/web/static/components.js +++ b/reaction_board/web/static/components.js @@ -127,6 +127,15 @@ export function metricChips(metrics, active, dataName = "metric") { )).join(""); } +export function centerActiveChips(root) { + root.querySelectorAll(".chip-row.scroll-x").forEach((row) => { + const active = row.querySelector(".chip.active"); + if (!active) return; + const target = active.offsetLeft - row.clientWidth / 2 + active.clientWidth / 2; + row.scrollLeft = Math.max(0, target); + }); +} + export function pager(page, pages) { if (!pages || pages <= 1) return ""; return `