Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-16029 IE11: image attachments aren't displayed #2924

Merged
merged 2 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/__snapshots__/size_aware_image.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ exports[`components/SizeAwareImage should render a placeholder and has loader wh
src="https://example.com/image.png"
style={
Object {
"display": "none",
"height": 1,
"position": "absolute",
"top": 0,
"visibility": "hidden",
"width": 1,
}
}
/>
Expand Down
8 changes: 6 additions & 2 deletions components/size_aware_image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class SizeAwareImage extends React.PureComponent {
} = this.props;

let placeHolder;
const shouldShowImg = !dimensions || this.state.loaded;
let imageStyleChangesOnLoad = {};

if (dimensions && dimensions.width && !this.state.loaded) {
placeHolder = (
Expand All @@ -120,6 +120,10 @@ export default class SizeAwareImage extends React.PureComponent {
Reflect.deleteProperty(props, 'onImageLoaded');
Reflect.deleteProperty(props, 'onImageLoadFail');

if (!this.state.loaded && dimensions) {
imageStyleChangesOnLoad = {position: 'absolute', top: 0, height: 1, width: 1, visibility: 'hidden'};
}

return (
<React.Fragment>
{placeHolder}
Expand All @@ -129,7 +133,7 @@ export default class SizeAwareImage extends React.PureComponent {
src={src}
onLoad={this.handleLoad}
onError={this.handleError}
style={{display: shouldShowImg ? 'initial' : 'none'}}
style={imageStyleChangesOnLoad}
/>
</React.Fragment>
);
Expand Down
9 changes: 5 additions & 4 deletions components/size_aware_image.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ describe('components/SizeAwareImage', () => {

loadImage.mockReturnValue(() => ({}));

test('should render an svg when first mounted with dimensions and img display set to none', () => {
test('should render an svg when first mounted with dimensions and img display set to position absolute', () => {
const wrapper = mount(<SizeAwareImage {...baseProps}/>);

const viewBox = wrapper.find('svg').prop('viewBox');
expect(viewBox).toEqual('0 0 300 200');
const style = wrapper.find('img').prop('style');
expect(style).toHaveProperty('display', 'none');
expect(style).toHaveProperty('position', 'absolute');
expect(style).toHaveProperty('visibility', 'hidden');
});

test('should render a placeholder and has loader when showLoader is true', () => {
Expand All @@ -44,12 +45,12 @@ describe('components/SizeAwareImage', () => {
expect(wrapper).toMatchSnapshot();
});

test('should have display set to initial in loaded state', () => {
test('should not have position absolute on image in loaded state', () => {
const wrapper = mount(<SizeAwareImage {...baseProps}/>);
wrapper.setState({loaded: true, error: false});

const style = wrapper.find('img').prop('style');
expect(style).toHaveProperty('display', 'initial');
expect(style).not.toHaveProperty('position', 'absolute');
});

test('should render the actual image when first mounted without dimensions', () => {
Expand Down
3 changes: 2 additions & 1 deletion sass/layout/_markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ h6 {
div.markdown-inline-img {
vertical-align: middle;
display: inline-block;
width: inherit;
sudheerDev marked this conversation as resolved.
Show resolved Hide resolved
width: 100%;
width: fill-available;
}
}

Expand Down