Commit becf15e5 by Peter Fogg

Give teams view error messages focus.

parent dccc36a4
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<div class="nav-item page"> <div class="nav-item page">
<div class="pagination-form"> <div class="pagination-form">
<label class="page-number-label" for="page-number-input"><%= gettext("Page number") %></label> <label class="page-number-label" for="page-number-input"><%= gettext("Page number") %></label>
<input id="page-number-input" class="page-number-input" name="page-number" type="text" size="4" autocomplete="off" /> <input id="page-number-input" class="page-number-input" name="page-number" type="text" size="4" autocomplete="off" aria-describedby="page-number-input-helper"/>
<span class="sr field-helper" id="page-number-input-helper"><%= gettext("Enter the page number you'd like to quickly navigate to.") %></span>
</div> </div>
<span class="current-page"><%= current_page %></span> <span class="current-page"><%= current_page %></span>
......
...@@ -16,6 +16,9 @@ define([ ...@@ -16,6 +16,9 @@ define([
}, },
expectError = function (text) { expectError = function (text) {
expect(teamsTabView.$('.warning').text()).toContain(text); expect(teamsTabView.$('.warning').text()).toContain(text);
},
expectFocus = function (element) {
expect(element.focus).toHaveBeenCalled();
}; };
beforeEach(function () { beforeEach(function () {
...@@ -40,6 +43,7 @@ define([ ...@@ -40,6 +43,7 @@ define([
course_id: 'test/course/id' course_id: 'test/course/id'
}).render(); }).render();
Backbone.history.start(); Backbone.history.start();
spyOn($.fn, 'focus');
}); });
afterEach(function () { afterEach(function () {
...@@ -58,17 +62,19 @@ define([ ...@@ -58,17 +62,19 @@ define([
expectContent('This is the new Teams tab.'); expectContent('This is the new Teams tab.');
}); });
it('displays an error message when trying to navigate to a nonexistent route', function () { it('displays and focuses an error message when trying to navigate to a nonexistent route', function () {
teamsTabView.router.navigate('test', {trigger: true}); teamsTabView.router.navigate('test', {trigger: true});
expectError('The page "test" could not be found.'); expectError('The page "test" could not be found.');
expectFocus(teamsTabView.$('.warning'));
}); });
it('displays an error message when trying to navigate to a nonexistent topic', function () { it('displays and focuses an error message when trying to navigate to a nonexistent topic', function () {
var requests = AjaxHelpers.requests(this); var requests = AjaxHelpers.requests(this);
teamsTabView.router.navigate('topics/test', {trigger: true}); teamsTabView.router.navigate('topics/test', {trigger: true});
AjaxHelpers.expectRequest(requests, 'GET', 'api/topics/test,course_id', null); AjaxHelpers.expectRequest(requests, 'GET', 'api/topics/test,course_id', null);
AjaxHelpers.respondWithError(requests, 404); AjaxHelpers.respondWithError(requests, 404);
expectError('The topic "test" could not be found.'); expectError('The topic "test" could not be found.');
expectFocus(teamsTabView.$('.warning'));
}); });
}); });
}); });
...@@ -255,6 +255,7 @@ ...@@ -255,6 +255,7 @@
var warningEl = this.$('.warning'); var warningEl = this.$('.warning');
warningEl.find('.copy').html('<p>' + message + '</p'); warningEl.find('.copy').html('<p>' + message + '</p');
warningEl.toggleClass('is-hidden', false); warningEl.toggleClass('is-hidden', false);
warningEl.focus();
}, },
hideWarning: function () { hideWarning: function () {
......
<div class="wrapper-msg is-incontext urgency-low warning is-hidden"> <div class="wrapper-msg is-incontext urgency-low warning is-hidden" tabindex="-1">
<div class="msg"> <div class="msg">
<div class="msg-content"> <div class="msg-content">
<div class="copy"> <div class="copy">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment