Skip to content

Commit

Permalink
MDL-58515 assignfeedback_editpdf: Fix comment tabbing and focus outline
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyjbutler committed Apr 17, 2017
1 parent 0714bcb commit e082fbd
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
6 changes: 6 additions & 0 deletions mod/assign/feedback/editpdf/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ ul.assignfeedback_editpdf_menu {
min-height: 1.2em;
}

.assignfeedback_editpdf_widget .commentdrawable textarea:focus {
outline: thin dotted #333;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}

.assignfeedback_editpdf_widget .commentdrawable {
display: inline-block;
z-index: 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,7 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
container.setAttribute('tabindex', '-1');
label.setAttribute('tabindex', '0');
node.setAttribute('tabindex', '-1');
menu.setAttribute('tabindex', '0');

if (!this.editor.get('readonly')) {
container.append(menu);
Expand Down Expand Up @@ -2681,6 +2682,8 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
if (node.collapse.delay) {
node.collapse.delay.cancel();
}
// Give comment a tabindex to prevent focus outline being suppressed.
node.setAttribute('tabindex', '0');
// Expand comment and pass focus to it.
node.expand();
node.focus();
Expand All @@ -2697,7 +2700,10 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
label.setAttribute('tabindex', '0');
}, this);

// Always restore label tabindex when leaving.
// Always restore the default tabindex states when moving away.
node.on('blur', function() {
node.setAttribute('tabindex', '-1');
}, this);
label.on('blur', function() {
label.setAttribute('tabindex', '0');
}, this);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,7 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
container.setAttribute('tabindex', '-1');
label.setAttribute('tabindex', '0');
node.setAttribute('tabindex', '-1');
menu.setAttribute('tabindex', '0');

if (!this.editor.get('readonly')) {
container.append(menu);
Expand Down Expand Up @@ -2681,6 +2682,8 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
if (node.collapse.delay) {
node.collapse.delay.cancel();
}
// Give comment a tabindex to prevent focus outline being suppressed.
node.setAttribute('tabindex', '0');
// Expand comment and pass focus to it.
node.expand();
node.focus();
Expand All @@ -2697,7 +2700,10 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
label.setAttribute('tabindex', '0');
}, this);

// Always restore label tabindex when leaving.
// Always restore the default tabindex states when moving away.
node.on('blur', function() {
node.setAttribute('tabindex', '-1');
}, this);
label.on('blur', function() {
label.setAttribute('tabindex', '0');
}, this);
Expand Down
8 changes: 7 additions & 1 deletion mod/assign/feedback/editpdf/yui/src/editor/js/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
container.setAttribute('tabindex', '-1');
label.setAttribute('tabindex', '0');
node.setAttribute('tabindex', '-1');
menu.setAttribute('tabindex', '0');

if (!this.editor.get('readonly')) {
container.append(menu);
Expand Down Expand Up @@ -304,6 +305,8 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
if (node.collapse.delay) {
node.collapse.delay.cancel();
}
// Give comment a tabindex to prevent focus outline being suppressed.
node.setAttribute('tabindex', '0');
// Expand comment and pass focus to it.
node.expand();
node.focus();
Expand All @@ -320,7 +323,10 @@ var COMMENT = function(editor, gradeid, pageno, x, y, width, colour, rawtext) {
label.setAttribute('tabindex', '0');
}, this);

// Always restore label tabindex when leaving.
// Always restore the default tabindex states when moving away.
node.on('blur', function() {
node.setAttribute('tabindex', '-1');
}, this);
label.on('blur', function() {
label.setAttribute('tabindex', '0');
}, this);
Expand Down

0 comments on commit e082fbd

Please sign in to comment.