Skip to content

Commit 953f269

Browse files
david-yz-liuclaude
andauthored
Fixed inline help icons not rendering in React components (#8316)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 543e10b commit 953f269

5 files changed

Lines changed: 55 additions & 6 deletions

File tree

‎Changelog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
- Added additional details to the account settings and renamed the Settings dropdown to Account (#8207)
4242

4343
### 🐛 Bug fixes
44+
- Fixed inline help icons not appearing in the Graders tab and starter file settings (#8316)
4445
- Fixed graders not being assigned to groups whose submissions have not been collected when skipping groups with empty submissions (#8315)
4546
- Fixed an error when changing an annotation's deduction on a result with no mark yet for the annotation category's criterion (#8313)
4647
- Fixed active marking criteria re-expanding immediately after being collapsed (#8309)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React, {useState} from "react";
2+
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
3+
import {faCircleQuestion} from "@fortawesome/free-regular-svg-icons";
4+
5+
/**
6+
* A help icon that toggles the display of its help text when clicked.
7+
*
8+
* This is the React equivalent of the `.inline-help` markup used in ERB views. Those elements are
9+
* set up by `common/help-system.js` when the page loads, which runs before React components render.
10+
*/
11+
export default function InlineHelp({children}) {
12+
const [isOpen, setIsOpen] = useState(false);
13+
14+
return (
15+
<div className="inline-help" onClick={() => setIsOpen(open => !open)}>
16+
<FontAwesomeIcon icon={faCircleQuestion} />
17+
<p style={{display: isOpen ? "block" : "none"}}>{children}</p>
18+
</div>
19+
);
20+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import InlineHelp from "../Helpers/inline_help";
2+
import {render, screen, fireEvent} from "@testing-library/react";
3+
4+
describe("InlineHelp", () => {
5+
let container;
6+
7+
beforeEach(() => {
8+
({container} = render(<InlineHelp>Some help text</InlineHelp>));
9+
});
10+
11+
it("renders a help icon", () => {
12+
expect(container.querySelector(".inline-help svg.fa-circle-question")).toBeInTheDocument();
13+
});
14+
15+
it("hides the help text initially", () => {
16+
expect(screen.getByText("Some help text")).not.toBeVisible();
17+
});
18+
19+
it("shows the help text when clicked", () => {
20+
fireEvent.click(container.querySelector(".inline-help"));
21+
expect(screen.getByText("Some help text")).toBeVisible();
22+
});
23+
24+
it("hides the help text when clicked again", () => {
25+
const help = container.querySelector(".inline-help");
26+
fireEvent.click(help);
27+
fireEvent.click(help);
28+
expect(screen.getByText("Some help text")).not.toBeVisible();
29+
});
30+
});

‎app/javascript/Components/graders_manager.jsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
66
import Table from "./table/table";
77
import {createColumnHelper} from "@tanstack/react-table";
88
import {caseSensitiveIncludes} from "./Helpers/table_helpers";
9+
import InlineHelp from "./Helpers/inline_help";
910
import {GraderDistributionModal} from "./Modals/graders_distribution_modal";
1011
import {SectionDistributionModal} from "./Modals/section_distribution_modal";
1112

@@ -371,9 +372,7 @@ class GradersManager extends React.Component {
371372
/>
372373
{I18n.t("graders.skip_empty_submissions")}
373374
</label>
374-
<div className="inline-help">
375-
<p>{I18n.t("graders.skip_empty_submissions_tooltip")}</p>
376-
</div>
375+
<InlineHelp>{I18n.t("graders.skip_empty_submissions_tooltip")}</InlineHelp>
377376
</div>
378377
<div style={{marginBottom: "1em"}}>
379378
<label>

‎app/javascript/Components/starter_file_manager.jsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import FileUploadModal from "./Modals/file_upload_modal";
55
import ReactTable from "react-table";
66
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
77
import {flashMessage} from "../common/flash";
8+
import InlineHelp from "./Helpers/inline_help";
89

910
function blurOnEnter(event) {
1011
if (event.key === "Enter") {
@@ -477,9 +478,7 @@ class StarterFileManager extends React.Component {
477478
/>
478479
{I18n.t("assignments.starter_file.available_after_due")}
479480
</label>
480-
<div className="inline-help">
481-
<p>{I18n.t("assignments.starter_file.available_after_due_help")}</p>
482-
</div>
481+
<InlineHelp>{I18n.t("assignments.starter_file.available_after_due_help")}</InlineHelp>
483482
</Fragment>
484483
);
485484
};

0 commit comments

Comments
 (0)