From 1af13a00f55f9f74330411aa0d1d6d355ae05a08 Mon Sep 17 00:00:00 2001 From: Isaac Janzen <50783505+janzenisaac@users.noreply.github.com> Date: Wed, 20 Dec 2023 09:05:58 -0700 Subject: [PATCH] DEV: Better calculations of list height (#39) --- javascripts/discourse/services/kanban-manager.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/javascripts/discourse/services/kanban-manager.js b/javascripts/discourse/services/kanban-manager.js index c324276..83822b3 100644 --- a/javascripts/discourse/services/kanban-manager.js +++ b/javascripts/discourse/services/kanban-manager.js @@ -121,9 +121,16 @@ export default class KanbanManager extends Service { const mainOutlet = document.querySelector("#main-outlet"); const mainOutletHeight = mainOutlet.getBoundingClientRect().height; const mainOutletPadding = 40; - const listControlsHeight = mainOutlet - .querySelector(".list-controls") - .getBoundingClientRect().height; + + // Get all previous siblings of the list container and add their heights + let currentElement = + mainOutlet.querySelector(".list-container").previousElementSibling; + let previousSiblingsHeight = 0; + while (currentElement !== null) { + previousSiblingsHeight += currentElement.getBoundingClientRect().height; + currentElement = currentElement.previousElementSibling; + } + const listTitleHeight = mainOutlet .querySelector(".list-title") .getBoundingClientRect().height; @@ -134,7 +141,7 @@ export default class KanbanManager extends Service { } else { height = mainOutletHeight - - listControlsHeight - + previousSiblingsHeight - listTitleHeight - mainOutletPadding; }