Skip to content

Commit

Permalink
Fix bugs related to annotation edit/delete in grading view (#7314)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-yz-liu authored Nov 30, 2024
1 parent 405b6dd commit 8085877
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
### 🐛 Bug fixes

- Ensure we handle JSON parsing exceptions when converting Jupyter Notebooks (#7308)
- Fixed bug in grading context menu for editing/deleting annotations (#7309)
- Fixed bug in grading annotations table when deleting annotations (#7309)

### 🔧 Internal changes

Expand Down
9 changes: 7 additions & 2 deletions app/assets/javascripts/Components/Result/pdf_viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ export class PDFViewer extends React.PureComponent {
}

update_pdf_view = () => {
this.pdfViewer.currentScaleValue = this.state.zoom;
this.pdfViewer.pagesRotation = this.state.rotation;
if (
!!document.getElementById("pdfContainer") &&
!!document.getElementById("pdfContainer").offsetParent
) {
this.pdfViewer.currentScaleValue = this.state.zoom;
this.pdfViewer.pagesRotation = this.state.rotation;
}
};

refresh_annotations = () => {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/Results/context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var annotation_context_menu = {
}
return "";
} else {
return clicked_element.attr("id").replace("annotation_holder_", "");
return clicked_element.id.replace("annotation_holder_", "");
}
}

Expand Down
23 changes: 23 additions & 0 deletions jest_after_env_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,26 @@ configure({adapter: new Adapter()});

// Jest fetch mock
require("jest-fetch-mock").enableMocks();

// Define HTMLElement.prototype.offsetParent
// Code from https://github.com/jsdom/jsdom/issues/1261#issuecomment-1765404346
Object.defineProperty(HTMLElement.prototype, "offsetParent", {
get() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
for (let element = this; element; element = element.parentNode) {
if (element.style?.display?.toLowerCase() === "none") {
return null;
}
}

if (this.stye?.position?.toLowerCase() === "fixed") {
return null;
}

if (this.tagName.toLowerCase() in ["html", "body"]) {
return null;
}

return this.parentNode;
},
});

0 comments on commit 8085877

Please sign in to comment.