From a4fa415f3f8f7ab625deae102e9fa781a0df4480 Mon Sep 17 00:00:00 2001 From: Will Barnett Date: Thu, 11 Apr 2024 16:39:11 +0100 Subject: [PATCH] Fixed creation of panel splitters in Layout so that panel layouts with an odd number of panels do no have an unnecessary splitter that causes a Metro exception o page resize, and added defensive check for fit() when no splitters are found. --- platform/src/EducationPlatformApp.js | 8 ++++---- platform/src/Layout.js | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/platform/src/EducationPlatformApp.js b/platform/src/EducationPlatformApp.js index 293074f..b1ff36d 100644 --- a/platform/src/EducationPlatformApp.js +++ b/platform/src/EducationPlatformApp.js @@ -532,11 +532,11 @@ class EducationPlatformApp { fit() { - var splitter = document.getElementById("splitter"); - splitter.style.minHeight = window.innerHeight + "px"; - splitter.style.maxHeight = window.innerHeight + "px"; - + if (splitter){ + splitter.style.minHeight = window.innerHeight + "px"; + splitter.style.maxHeight = window.innerHeight + "px"; + } this.panels.forEach(panel => panel.fit()); this.preloader.hide(); } diff --git a/platform/src/Layout.js b/platform/src/Layout.js index 9d54023..05854b7 100644 --- a/platform/src/Layout.js +++ b/platform/src/Layout.js @@ -89,7 +89,13 @@ class Layout { // Create the splitters for the row let splitProportions = ("10, ".repeat(numberOfRows)); // Add a proportion per splitter - verticalSplitters.push ( Layout.createVerticalSplitter( panelsToLayout.map( pn => pn.getElement() ), splitProportions) ); + + if (panelsToLayout.length > 1) { + verticalSplitters.push( Layout.createVerticalSplitter( panelsToLayout.map( pn => pn.getElement() ), splitProportions) ); + } else { + // No splitter required for a single panel + verticalSplitters.push( panelsToLayout[0].getElement() ); + } } if (numberOfColumns > 1) {