fix issue pressing enter to submit form

fixes CNVS-21292

Button type wasn't set on a form button which was causing issues

Test Plan
Given I'm a user that can create modules(chrome, safari, firefox)
And I'm on the modules page
When I click "Add Module"
And fill in a module name
And press enter
Then the form should submit
And the dialog should close
And the new module should appear on the page

Change-Id: I7149fc956dc8ef787b2026fbda89e2663757cfdb
Reviewed-on: https://gerrit.instructure.com/56826
Tested-by: Jenkins
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Sterling Cobb <sterling@instructure.com>
This commit is contained in:
Sterling Cobb 2015-06-18 17:02:20 -06:00
parent 25540dd05a
commit 5247903f94
9 changed files with 21 additions and 20 deletions

View File

@ -10,7 +10,8 @@ define [
$dialog = $(this)
$buttons = $dialog.find(".button-container:last .btn, button[type=submit]")
if $buttons.length
$dialog.find(".button-container:last, button[type=submit]").hide()
# position hack for safari to still see the submit buttons
$dialog.find(".button-container:last, button[type=submit]").css({position:"absolute",left:"-9999px"})
buttons = $.map $buttons.toArray(), (button) ->
$button = $(button)
classes = $button.attr('class') ? ''

View File

@ -327,7 +327,7 @@ TEXT
</span>
</div>
<div style="float: right;">
<button class="delete_criterion_link dim-till-hover" aria-label="<%= t('button.delete_label', %{Delete prerequisites}) %>" title="<%= t('button.delete_title', %{Delete prerequisites}) %>"><i class="icon-end standalone-icon" ></i></button>
<button type="button" class="delete_criterion_link dim-till-hover" aria-label="<%= t('button.delete_label', %{Delete prerequisites}) %>" title="<%= t('button.delete_title', %{Delete prerequisites}) %>"><i class="icon-end standalone-icon" ></i></button>
</div>
<div class="clear"></div>
</div>

View File

@ -36,9 +36,7 @@ define [
ok $dialog.is(':ui-dialog:visible'), 'pops up dialog'
equal $dialog.dialog('option', 'buttons').length, 2, 'converts both buttons in .button-pane only'
msg = "hides the original .buttons in the .button-container only"
$dialog.find('.btn').each ->
equal $(this).is(':hidden'), ($(this).text() isnt 'Should NOT be converted'), msg
equal $dialog.find('.button-container').first().css('left'), '-9999px', "moves the original .buttons in the .button-container should have an offeset of -999px"
msg = "make sure clicking on converted ui-dialog-button causes submit handler to be called on form"
$submitButton = $dialog.dialog('widget').find('.ui-dialog-buttonpane .ui-button:contains("This will Submit the form")')

View File

@ -48,7 +48,9 @@ describe "external tool assignments" do
ff('#context_external_tools_select td .tools .tool')[1].click
expect(f('#context_external_tools_select input#external_tool_create_url')).to have_attribute('value', @t2.url)
end
fj('.add_item_button:visible').click
fj('.add_item_button.ui-button').click
expect(f('#assignment_external_tool_tag_attributes_url')).to have_attribute('value', @t2.url)
expect_new_page_load { submit_form('#edit_assignment_form') }
@ -71,7 +73,7 @@ describe "external tool assignments" do
f('#assignment_external_tool_tag_attributes_url').click
ff('#context_external_tools_select td .tools .tool')[0].click
expect(f('#context_external_tools_select input#external_tool_create_url')).to have_attribute('value', @t1.url)
fj('.add_item_button:visible').click
fj('.add_item_button.ui-button').click
expect(f('#assignment_external_tool_tag_attributes_url')).to have_attribute('value', @t1.url)
expect_new_page_load { submit_form('#edit_assignment_form') }

View File

@ -116,7 +116,7 @@ describe "context modules" do
click_option('#add_module_item_select', 'wiki_page', :value)
click_option('#wiki_pages_select .module_item_select', 'new', :value)
replace_content(f('#wiki_pages_select .item_title'), 'new page')
fj('.add_item_button:visible').click
fj('.add_item_button.ui-button').click
wait_for_ajaximations
new_page = WikiPage.last
@ -149,7 +149,7 @@ describe "context modules" do
replace_content(f('#content_tag_create_url'), 'http://www.example.com')
replace_content(f('#content_tag_create_title'), 'new item')
fj('.add_item_button:visible').click
fj('.add_item_button.ui-button').click
wait_for_ajaximations
new_tag = ContentTag.last
@ -160,4 +160,4 @@ describe "context modules" do
expect(link).not_to be_displayed
end
end
end
end

View File

@ -149,7 +149,7 @@ describe "context modules" do
expect(edit_form).to be_displayed
f('.completion_entry .delete_criterion_link', edit_form).click
wait_for_ajaximations
ff('.cancel_button', dialog_for(edit_form)).last.click
ff('.cancel_button.ui-button', dialog_for(edit_form)).last.click
wait_for_ajaximations
# now delete the criterion frd
@ -344,7 +344,7 @@ describe "context modules" do
replace_content(f('#sub_header_title'), header_text)
true
end
fj('.add_item_button:visible').click
fj('.add_item_button.ui-button').click
wait_for_ajaximations
tag = ContentTag.last
module_item = f("#context_module_item_#{tag.id}")
@ -381,7 +381,7 @@ describe "context modules" do
wait_for_ajaximations
keep_trying_until do
select_module_item('#add_module_item_select', 'External Tool')
fj('.add_item_button:visible').click
fj('.add_item_button.ui-button').click
expect(ff('.alert.alert-error').length).to eq 1
end
expect(fj('.alert.alert-error:visible').text).to eq "An external tool can't be saved without a URL."
@ -414,7 +414,7 @@ describe "context modules" do
option = first_selected_option(prereq_select)
expect(option.text).to eq 'the module, ' + first_module_name
ff('.cancel_button', dialog_for(add_form)).last.click
ff('.cancel_button.ui-button', dialog_for(add_form)).last.click
wait_for_ajaximations
mod2.publish!
@ -518,7 +518,7 @@ describe "context modules" do
it "should return focus to the cog menu when closing the edit dialog for an item" do
hover_and_click("#context_module_item_#{@tag.id} .edit_item_link")
keep_trying_until { fj('.cancel_button:visible') }.click
keep_trying_until { ff('.cancel_button.ui-button')[2] }.click
check_element_has_focus(fj("#context_module_item_#{@tag.id} .al-trigger"))
end

View File

@ -66,7 +66,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
wait_for_ajaximations
select_module_item('#add_module_item_select', module_name)
select_module_item(item_select_selector + ' .module_item_select', item_name)
fj('.add_item_button:visible').click
fj('.add_item_button.ui-button').click
wait_for_ajaximations
tag = ContentTag.last
module_item = f("#context_module_item_#{tag.id}")
@ -111,7 +111,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
end
replace_content(item_title, item_title_text)
yield if block_given?
fj('.add_item_button:visible').click
fj('.add_item_button.ui-button').click
wait_for_ajaximations
tag = ContentTag.last
module_item = f("#context_module_item_#{tag.id}")
@ -132,7 +132,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
replace_content(title_input, page_name_text)
fj('.add_item_button:visible').click
fj('.add_item_button.ui-button').click
wait_for_ajaximations
tag = ContentTag.last
module_item = f("#context_module_item_#{tag.id}")

View File

@ -71,7 +71,7 @@ shared_examples_for "quiz question selenium tests" do
def accept_cant_go_back_warning
expect_new_page_load {
fj("button:contains('Begin'):visible").click
fj("button:contains('Begin').ui-button").click
}
wait_for_ajaximations
end

View File

@ -40,4 +40,4 @@ describe 'Global Navigation' do
end
end
end
end
end