Commit 9d3508b1 authored by Harrison Healey's avatar Harrison Healey Committed by Carlos Tadeu Panato Junior

MM-10706 Made sure to update post height when image loads (#1315)

parent 6996bb5e
......@@ -56,9 +56,26 @@ export default class MarkdownImage extends React.PureComponent {
if (this.heightTimeout !== 0) {
clearTimeout(this.heightTimeout);
this.heightTimeout = 0;
return true;
}
return false;
}
handleLoad = () => {
const wasWaiting = this.stopWaitingForHeight();
// The image loaded before we caught its layout event, so we still need to notify that its height changed
if (wasWaiting && this.props.onHeightReceived) {
this.props.onHeightReceived(this.refs.image.height);
}
};
handleError = () => {
this.stopWaitingForHeight();
};
render() {
const props = {...this.props};
Reflect.deleteProperty(props, 'onHeightReceived');
......@@ -67,8 +84,8 @@ export default class MarkdownImage extends React.PureComponent {
<img
ref='image'
{...props}
onLoad={this.stopWaitingForHeight}
onError={this.stopWaitingForHeight}
onLoad={this.handleLoad}
onError={this.handleError}
/>
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment