summaryrefslogtreecommitdiffstats
path: root/core/src/jquery
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2022-05-31 01:22:37 +0000
committerChristopher Ng <chrng8@gmail.com>2022-06-09 00:17:19 +0000
commit189926b107945adfa3e4c7c9542d15a1ace0340a (patch)
tree67c54aeb330058720635673fffde2765e8aea2fd /core/src/jquery
parent9f09caaaeacb8488a058b956357f363ddfd2fc9e (diff)
downloadnextcloud-server-189926b107945adfa3e4c7c9542d15a1ace0340a.tar.gz
nextcloud-server-189926b107945adfa3e4c7c9542d15a1ace0340a.zip
Add a11y utility function
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'core/src/jquery')
-rw-r--r--core/src/jquery/ocdialog.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/src/jquery/ocdialog.js b/core/src/jquery/ocdialog.js
index 17f466e7cb1..31fbf3a333a 100644
--- a/core/src/jquery/ocdialog.js
+++ b/core/src/jquery/ocdialog.js
@@ -24,6 +24,7 @@
*/
import $ from 'jquery'
+import { isA11yClick } from '../Util/a11y'
$.widget('oc.ocdialog', {
options: {
@@ -60,7 +61,7 @@ $.widget('oc.ocdialog', {
if (self.element.find('input').length === 1) {
const $input = self.element.find('input')
$input.on('keydown', function(event) {
- if (event.key === 'Enter') {
+ if (isA11yClick(event)) {
if (self.$buttonrow) {
const $button = self.$buttonrow.find('button.primary')
if ($button && !$button.prop('disabled')) {
@@ -157,7 +158,7 @@ $.widget('oc.ocdialog', {
}
self.$buttonrow.append($button)
$button.on('click keydown', function(event) {
- if (event.type === 'click' || (event.type === 'keydown' && event.key === 'Enter')) {
+ if (isA11yClick(event)) {
val.click.apply(self.element[0], arguments)
}
})
@@ -179,7 +180,7 @@ $.widget('oc.ocdialog', {
const $closeButton = $('<a class="oc-dialog-close" tabindex="0"></a>')
this.$dialog.prepend($closeButton)
$closeButton.on('click keydown', function(event) {
- if (event.type === 'click' || (event.type === 'keydown' && event.key === 'Enter')) {
+ if (isA11yClick(event)) {
self.options.closeCallback && self.options.closeCallback()
self.close()
}