Skip to content

Commit

Permalink
fixed theme also being applied inside an iFrame (#216)
Browse files Browse the repository at this point in the history
- closes #114
  • Loading branch information
foxriver76 authored Nov 28, 2023
1 parent f8f3919 commit 4aed6d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ E.g., if it was used in a menu and the menu is red, the circle would be red.
### **WORK IN PROGRESS**
* (foxriver76) recalculate fields after moving widgets
* (foxriver76) fixed pasting group on other view
* (foxriver76) fixed theme also applied in iframe
* (bluefox) implemented Basic Image as react widget

### 2.9.0 (2023-11-27)
Expand Down
9 changes: 8 additions & 1 deletion src/src/bootstrap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ function modifyClasses(className, addClass, removeClass) {
return classes.join(' ');
}

/**
* Checks if vis is rendered inside an iFrame
*
* @return {boolean}
*/
function inIframe() {
try {
return window.self !== window.top;
} catch (e) {
} catch {
return true;
}
}
Expand Down Expand Up @@ -91,6 +96,8 @@ const ThemeContainer = () => {
} else {
window.document.body.className = modifyClasses(window.document.body.className, 'body-light', 'body-dark');
}
} else {
window.document.body.className = '';
}

return <StylesProvider generateClassName={generateClassName}>
Expand Down

0 comments on commit 4aed6d2

Please sign in to comment.