From e7f73e1fe52facfabf8eda990b80ea5b0076aef4 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Wed, 13 Jul 2022 07:37:17 -0500 Subject: [PATCH] Make knowls wait until the page css has loaded before initializing. This fixes issue https://github.com/openwebwork/webwork2/issues/1739. In the PG problem editor, the page in the iframe is not displayed until after the page loads. As such the javascript getComputedStyle method fails. The same things happens with the graphtool. The same solution is now implemented for knowls. --- htdocs/js/apps/Knowls/knowl.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/js/apps/Knowls/knowl.js b/htdocs/js/apps/Knowls/knowl.js index bdfcbac8c4..57b8388a40 100644 --- a/htdocs/js/apps/Knowls/knowl.js +++ b/htdocs/js/apps/Knowls/knowl.js @@ -15,6 +15,11 @@ }; const initializeKnowl = (knowl) => { + if (getComputedStyle(knowl)?.display === '') { + setTimeout(() => initializeKnowl(knowl), 100); + return; + } + knowl.dataset.bsToggle = 'collapse'; if (!knowl.knowlContainer) { knowl.knowlContainer = document.createElement('div');