Material-ui: [Dialog] autoDetectWindowHeight issue with images

Created on 14 Dec 2015  路  2Comments  路  Source: mui-org/material-ui

If there a big image inside the new Dialog a part of it will be rendered outside of the view port because he detecting height before the image load.

I solve this on my side by having this callback: window.dispatchEvent(new Event('resize'));
on onLoad of <img />

bug 馃悰

Most helpful comment

Ran into this issue, fixed by preloading the image first, before opening dialog and setting its contents:

const image = new Image();
image.onload = () => {
    this.setState({
        previewOpen: true,
        dialogContent: <img style={imgStyle} src={imgPath}/>
    });
};
image.src = imgPath;

All 2 comments

The weird thing is that the image is not even load remotely its a props passed down. Look like
<img src={'data:image/png;base64, ' + this.props.position.image} /> is async and causing the image getting rendered in a different loop

Ran into this issue, fixed by preloading the image first, before opening dialog and setting its contents:

const image = new Image();
image.onload = () => {
    this.setState({
        previewOpen: true,
        dialogContent: <img style={imgStyle} src={imgPath}/>
    });
};
image.src = imgPath;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

ghost picture ghost  路  3Comments

FranBran picture FranBran  路  3Comments

ryanflorence picture ryanflorence  路  3Comments

TimoRuetten picture TimoRuetten  路  3Comments