0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 14:22:52 +00:00

Force browser repaint after closing Print dialog

This commit is contained in:
Trevor Buckner
2024-05-23 17:08:24 -04:00
parent a227a792c0
commit 24769d69d4
5 changed files with 42 additions and 18 deletions

View File

@@ -35,12 +35,23 @@ const SharePage = createClass({
if(!(e.ctrlKey || e.metaKey)) return;
const P_KEY = 80;
if(e.keyCode == P_KEY){
if(e.keyCode == P_KEY) window.frames['BrewRenderer'].contentWindow.print();
if(e.keyCode == P_KEY) this.printPage();
e.stopPropagation();
e.preventDefault();
}
},
printPage : function(){
if (window.typeof !== 'undefined') {
window.frames['BrewRenderer'].contentWindow.print();
//Force DOM reflow; Print dialog causes a repaint, and @media print CSS somehow makes out-of-view pages disappear
let node = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0);
node.style.display='none';
node.offsetHeight; // accessing this is enough to trigger a reflow
node.style.display='';
}
},
processShareId : function() {
return this.props.brew.googleId && !this.props.brew.stubbed ?
this.props.brew.googleId + this.props.brew.shareId :
@@ -72,7 +83,7 @@ const SharePage = createClass({
<Nav.section>
{this.props.brew.shareId && <>
<PrintNavItem/>
<PrintNavItem printFunction={this.printPage}/>
<Nav.dropdown>
<Nav.item color='red' icon='fas fa-code'>
source