Skip to content

Commit

Permalink
Make knowls wait until the page css has loaded before initializing.
Browse files Browse the repository at this point in the history
This fixes issue openwebwork/webwork2#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.
  • Loading branch information
drgrice1 committed Jul 13, 2022
1 parent d3288f9 commit e7f73e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions htdocs/js/apps/Knowls/knowl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit e7f73e1

Please sign in to comment.