From c2ebe33f774401101e6a20d96331fe039e72c9c6 Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Thu, 21 Dec 2017 14:06:25 +0800 Subject: [PATCH] MDL-43827 filepicker: Multiple actions not accessible using keyboard --- lib/form/filemanager.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/form/filemanager.js b/lib/form/filemanager.js index 5d37e48c052..279712e8b0b 100644 --- a/lib/form/filemanager.js +++ b/lib/form/filemanager.js @@ -781,6 +781,7 @@ M.form_filemanager.init = function(Y, options) { }, setup_select_file: function() { var selectnode = this.selectnode; + var scope = this; // bind labels with corresponding inputs selectnode.all('.fp-saveas,.fp-path,.fp-author,.fp-license').each(function (node) { node.all('label').set('for', node.one('input,select').generateID()); @@ -791,12 +792,10 @@ M.form_filemanager.init = function(Y, options) { e.preventDefault(); this.update_file(); }, this); - selectnode.all('form').on('keydown', function(e) { - if (e.keyCode == 13) { - e.preventDefault(); - this.update_file(); - } - }, this); + selectnode.all('form input').on('key', function(e) { + e.preventDefault(); + scope.update_file(); + }, 'enter'); selectnode.one('.fp-file-download').on('click', function(e) { e.preventDefault(); if (this.selectui.fileinfo.type != 'folder') { @@ -915,6 +914,11 @@ M.form_filemanager.init = function(Y, options) { // TODO if changed asked to confirm, the same with close button this.selectui.hide(); }, this); + selectnode.all('.fp-file-update, .fp-file-download, .fp-file-delete, .fp-file-zip, .fp-file-unzip, ' + + '.fp-file-setmain, .fp-file-cancel').on('key', function(e) { + e.preventDefault(); + this.simulate('click'); + }, 'enter'); }, get_parent_folder_name: function(node) { if (node.type != 'folder' || node.filepath.length < node.fullname.length+1) {