Skip to content

Commit cfb7f20

Browse files
authored
Fixed bugs in ImageViewer load and annotations (#7485)
1 parent f90cff0 commit cfb7f20

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
- Fix tag creation failing in tags table (#7426)
2727
- Ensure tag names are unique within an assignment (#7430)
2828
- Update flash style to "notice" for "setting up test env" message (#7445)
29+
- Fixed bug in `ImageViewer` where image width was set to 0 on initial load (#7485)
30+
- Fixed bug in `ImageViewer` where annotations did not disappear when moving the mouse out of the image (#7485)
2931

3032
### 🔧 Internal changes
3133

app/assets/javascripts/Annotations/image_annotation_manager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ImageAnnotationManager extends AnnotationManager {
7777
} else {
7878
holder.style.cursor = "auto";
7979
}
80+
holder.onmouseleave = this.check_for_annotations.bind(this);
8081

8182
this.image_preview.parentNode.insertBefore(holder, this.image_preview);
8283
}
@@ -201,6 +202,7 @@ class ImageAnnotationManager extends AnnotationManager {
201202
holder.onmousemove = this.check_for_annotations.bind(this);
202203
holder.onmousedown = this.start_select_box.bind(this);
203204
holder.onmouseup = null;
205+
holder.onmouseleave = this.check_for_annotations.bind(this);
204206
}
205207
}
206208

app/javascript/Components/Result/image_viewer.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ export class ImageViewer extends React.PureComponent {
2626
}
2727

2828
componentDidMount() {
29-
this.setImageURL().then(() => {
30-
document.getElementById("image_preview").onload = () => {
31-
this.display_annotations();
32-
this.adjustPictureSize();
33-
this.rotateImage();
34-
};
35-
});
29+
this.setImageURL();
3630
}
3731

3832
componentWillUnmount() {
@@ -231,7 +225,11 @@ export class ImageViewer extends React.PureComponent {
231225
src={this.state.url}
232226
data-zoom={this.state.zoom}
233227
className={this.props.released_to_students ? "" : "enable-annotations"}
234-
onLoad={this.display_annotations}
228+
onLoad={() => {
229+
this.display_annotations();
230+
this.adjustPictureSize();
231+
this.rotateImage();
232+
}}
235233
alt={I18n.t("results.cant_display_image")}
236234
/>
237235
</div>

0 commit comments

Comments
 (0)