Skip to content

Commit

Permalink
MDL-65539 formats: Section labels not updated during move
Browse files Browse the repository at this point in the history
Before this change when moving a section via drag and drop the
aria-label for the section was not being updated neither was the
title on the drag handle.

The result was the the drop menu on keyboard drag and drop displayed
the wrong information after a section was moved.
  • Loading branch information
NeillM committed Apr 3, 2020
1 parent 1d4fdb0 commit dc489df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions course/format/topics/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ M.course.format.swap_sections = function(Y, node1, node2) {
* Process sections after ajax response
*
* @param {YUI} Y YUI3 instance
* @param {NodeList} sectionlist of sections
* @param {array} response ajax response
* @param {string} sectionfrom first affected section
* @param {string} sectionto last affected section
Expand Down Expand Up @@ -76,13 +77,14 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
// Update section title.
var content = Y.Node.create('<span>' + response.sectiontitles[i] + '</span>');
sectionlist.item(i).all('.'+CSS.SECTIONNAME).setHTML(content);
// Update move icon.
ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE);
str = ele.getAttribute('alt');
// Update the drag handle.
ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE).ancestor('.section-handle');
str = ele.getAttribute('title');
stridx = str.lastIndexOf(' ');
newstr = str.substr(0, stridx +1) + i;
ele.setAttribute('alt', newstr);
ele.setAttribute('title', newstr); // For FireFox as 'alt' is not refreshed.
ele.setAttribute('title', newstr);
// Update the aria-label for the section.
sectionlist.item(i).setAttribute('aria-label', content.get('innerText').trim());
}
}
}
12 changes: 7 additions & 5 deletions course/format/weeks/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ M.course.format.swap_sections = function(Y, node1, node2) {
* Process sections after ajax response
*
* @param {YUI} Y YUI3 instance
* @param {NodeList} sectionlist of sections
* @param {array} response ajax response
* @param {string} sectionfrom first affected section
* @param {string} sectionto last affected section
Expand Down Expand Up @@ -77,13 +78,14 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
var content = Y.Node.create('<span>' + response.sectiontitles[i] + '</span>');
sectionlist.item(i).all('.'+CSS.SECTIONNAME).setHTML(content);

// Update move icon.
ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE);
str = ele.getAttribute('alt');
// Update the drag handle.
ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE).ancestor('.section-handle');
str = ele.getAttribute('title');
stridx = str.lastIndexOf(' ');
newstr = str.substr(0, stridx +1) + i;
ele.setAttribute('alt', newstr);
ele.setAttribute('title', newstr); // For FireFox as 'alt' is not refreshed.
ele.setAttribute('title', newstr);
// Update the aria-label for the section.
sectionlist.item(i).setAttribute('aria-label', content.get('innerText').trim());

// Remove the current class as section has been moved.
sectionlist.item(i).removeClass('current');
Expand Down

0 comments on commit dc489df

Please sign in to comment.