Skip to content

Commit

Permalink
MDL-76150 gradereport_grader: dropdowns were partly covered during behat
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies authored and sarjona committed Apr 6, 2023
1 parent 84a0ad1 commit 06a4898
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion grade/report/grader/amd/build/stickycolspan.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion grade/report/grader/amd/build/stickycolspan.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 18 additions & 16 deletions grade/report/grader/amd/src/stickycolspan.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,34 @@ const SELECTORS = {
* Initialize module
*/
export const init = () => {
if (document.querySelector(SELECTORS.BEHAT)) {
return;
}
const grader = document.querySelector(SELECTORS.GRADEPARENT);
const studentHeader = grader.querySelector(SELECTORS.STUDENTHEADER);
const leftOffset = getComputedStyle(studentHeader).getPropertyValue('left');
const rightOffset = getComputedStyle(studentHeader).getPropertyValue('right');

const tableHeaders = grader.querySelectorAll(SELECTORS.TABLEHEADER);

let i = 0;
tableHeaders.forEach((tableHeader) => {
if (tableHeader.colSpan > 1) {
const addOffset = (tableHeader.offsetWidth - studentHeader.offsetWidth);
if (window.right_to_left()) {
tableHeader.style.right = 'calc(' + rightOffset + ' - ' + addOffset + 'px )';
} else {
tableHeader.style.left = 'calc(' + leftOffset + ' - ' + addOffset + 'px )';
}
} else {
if (tableHeader.colSpan <= 1) {
tableHeader.style.zIndex = tableHeaders.length - i;
}
i++;
});

let tableHeader = grader.querySelector(SELECTORS.TABLEHEADING);
const tableHeader = grader.querySelector(SELECTORS.TABLEHEADING);
tableHeader.style.zIndex = tableHeaders.length + 1;

if (!document.querySelector(SELECTORS.BEHAT)) {
const studentHeader = grader.querySelector(SELECTORS.STUDENTHEADER);
const leftOffset = getComputedStyle(studentHeader).getPropertyValue('left');
const rightOffset = getComputedStyle(studentHeader).getPropertyValue('right');

tableHeaders.forEach((tableHeader) => {
if (tableHeader.colSpan > 1) {
const addOffset = (tableHeader.offsetWidth - studentHeader.offsetWidth);
if (window.right_to_left()) {
tableHeader.style.right = 'calc(' + rightOffset + ' - ' + addOffset + 'px )';
} else {
tableHeader.style.left = 'calc(' + leftOffset + ' - ' + addOffset + 'px )';
}
}
});
}
};

0 comments on commit 06a4898

Please sign in to comment.