Skip to content

Commit c4e15c0

Browse files
committed
fix attachment button to work with keyboard-only
closes: CNVS-16994 this worked before but it broke in 2cfd50d when we tried to get it to work in IE10 Test plan: - Perform the following without and with a screen reader, in IE10, IE11, firefox, safari, & chrome - Navigate to the compose dialog in conversations. - Using the keyboard, tab to the "Add Attachment" button. - Using the keyboard, verify that an attachment can in fact be attached to a message, and that message sent. - Reverify the above in IE with Jaws, Firefox with NVDA, and Safari with VO. Change-Id: Iad232a019fcb3102bb33def46e147b49d5b03b07 Reviewed-on: https://gerrit.instructure.com/46970 Tested-by: Jenkins Reviewed-by: Andrew Butterfield <abutterfield@instructure.com> QA-Review: Steven Shepherd <sshepherd@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com>
1 parent 68b6727 commit c4e15c0

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

app/coffeescripts/views/conversations/MessageFormDialog.coffee

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ define [
147147
@$fullDialog.addClass('compose-message-dialog')
148148

149149
# add attachment and media buttons to bottom bar
150-
@$fullDialog.find('.ui-dialog-buttonpane').prepend composeButtonBarTemplate()
150+
@$fullDialog.find('.ui-dialog-buttonpane').prepend composeButtonBarTemplate({isIE10: INST.browser.ie10})
151151

152152
@$addMediaComment = @$fullDialog.find('.attach-media')
153153

@@ -338,14 +338,20 @@ define [
338338
($attachments.length * $attachments.outerWidth()) > @$attachmentsPane.width()
339339

340340
addAttachment: ->
341-
# when you click on the "label" that references the input it automatically open the file input
342-
# we're exploiting this to get around the fact that IE won't let you submit the form when you try to
343-
# "click" it through the javascript
344-
345341
$('#file_input').attr('id', _.uniqueId('file_input'))
346342
@appendAddAttachmentTemplate()
347343
@updateAttachmentOverflow()
348-
@focusAddAttachment()
344+
345+
# Hacky crazyness for ie10.
346+
# If you try to use javascript to 'click' on a file input element,
347+
# when you go to submit the form it will give you an "access denied" error.
348+
# So, for IE10, we make the paperclip icon a <label> that references the input it automatically open the file input.
349+
# But making it a <label> makes it so you can't tab to it. so for everyone else me make it a <button> and open the file
350+
# input dialog with a javascript "click"
351+
if INST.browser.ie10
352+
@focusAddAttachment()
353+
else
354+
@$fullDialog.find('.file_input:last').click()
349355

350356
appendAddAttachmentTemplate: ->
351357
$attachment = $(addAttachmentTemplate())

app/views/jst/conversations/composeButtonBar.handlebars

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<div class="ui-dialog-buttonset attachments">
2-
<label for="file_input" class="ui-button ui-widget ui-state-default ui-corner-all attach-file"
3-
type="button" role="button"
2+
<{{#if isIE10}}label for="file_input" role="button"{{else}}button{{/if}}
3+
class="ui-button ui-widget ui-state-default ui-corner-all attach-file"
4+
type="button"
45
title="{{#t "titles.add_attachment"}}Add an attachment{{/t}}">
56
<span class="ui-button-text">
67
<i class="icon-paperclip"></i>
78
<span class="screenreader-only">
89
{{#t "titles.add_attachment"}}Add an attachment{{/t}}
910
</span>
1011
</span>
11-
</label>
12+
</{{#if isIE10}}label{{else}}button{{/if}}>
1213

1314
<button class="ui-button ui-widget ui-state-default ui-corner-all attach-media"
1415
type="button"

0 commit comments

Comments
 (0)