Closing the edit dialog on modules items sets focus back to cog menu

fixes CNVS-18845

Test Plan:
	- Go to the modules page
	- Edit a module item using keyboard only
	- Close the dialog with either ESC or the close buttons
	- Focus should return to the cog menu.

Change-Id: Ied89c292e3300aa7b5b5e30dba47d86d47a1ab84
Reviewed-on: https://gerrit.instructure.com/49468
Tested-by: Jenkins
QA-Review: Nathan Rogowski <nathan@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
This commit is contained in:
Clay Diffrient 2015-02-25 11:45:25 -07:00
parent 25989dfae9
commit 38ebdf223e
3 changed files with 16 additions and 1 deletions

View File

@ -129,7 +129,7 @@
<i class="icon-<%= published_status %>"></i>
</span>
<div class="inline-block" role=application">
<div class="inline-block cog-menu-container" role=application">
<a class="al-trigger al-trigger-gray" role="button" tabindex="0" href="#">
<i class="icon-settings"></i><i class="icon-mini-arrow-down"></i>
<span class="screenreader-only"><%= t('settings', 'Settings') %></span>

View File

@ -850,6 +850,7 @@ define([
});
$(".edit_item_link").live('click', function(event) {
event.preventDefault();
var $cogLink = $(this).closest('.cog-menu-container').children('.al-trigger');
var $item = $(this).parents(".context_module_item");
var data = $item.getTemplateData({textValues: ['title', 'url', 'indent', 'new_tab']});
data.indent = modules.currentIndent($item);
@ -861,6 +862,9 @@ define([
open: function(){
$(this).find('input[type=text],textarea,select').first().focus();
},
close: function () {
$cogLink.focus();
},
minWidth: 320
}).fixDialogButtons();
});

View File

@ -618,6 +618,17 @@ describe "context_modules" do
expect(tag.indent).to eq 1
end
it "should return focus to the cog menu when closing the edit dialog for an item" do
get "/courses/#{@course.id}/modules"
add_existing_module_item('#assignments_select', 'Assignment', @assignment.title)
tag = ContentTag.last
f("#context_module_item_#{tag.id} .al-trigger").click
hover_and_click("#context_module_item_#{tag.id} .edit_item_link")
keep_trying_until { fj('.cancel_button:visible') }.click
check_element_has_focus(fj("#context_module_item_#{tag.id} .al-trigger"))
end
it "should still display due date and points possible after indent change" do
get "/courses/#{@course.id}/modules"