Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow expand/collapse of targeted feedback groups #5642

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 13 additions & 0 deletions app/assets/javascripts/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function initSubmissionShow(parentClass: string, mediaPath: string, token: strin
initTabLinks();
initCollapseButtons();
initHideCorrect();
initTabSummaryLinks();
contextualizeMediaPaths(parentClass, mediaPath, token);
}

Expand Down Expand Up @@ -38,6 +39,18 @@ function initSubmissionShow(parentClass: string, mediaPath: string, token: strin
});
}

function initTabSummaryLinks(): void {
document.querySelectorAll(".tab-summary-icons a").forEach(l => {
l.addEventListener("click", () => {
// The href is a hash followed by the id of the group
// We remove the hash and get the group by id
const groupId = l.attributes["href"].value.substring(1);
const group = document.getElementById(groupId);
group.classList.remove("collapsed");
});
});
}

function initHideCorrect(): void {
document.querySelectorAll(".correct-switch-buttons .btn").forEach( b => {
b.addEventListener("click", e => {
Expand Down
7 changes: 1 addition & 6 deletions app/assets/stylesheets/models/submissions.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,7 @@
}
}

&:target .btn-collapse {
pointer-events: none;
}

// if a group is the target, never collapse
&.collapsed:not(:target) {
&.collapsed {
.card-supporting-text {
display: none;
}
Expand Down