summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2022-05-27 22:02:01 +0000
committerChristopher Ng <chrng8@gmail.com>2022-06-09 00:16:04 +0000
commit9f09caaaeacb8488a058b956357f363ddfd2fc9e (patch)
tree759e22bfd53acfa42d6cf0b683340342e9398101 /core/src
parentedba92d1f4bc9de0c3efff860aead3587b587374 (diff)
downloadnextcloud-server-9f09caaaeacb8488a058b956357f363ddfd2fc9e.tar.gz
nextcloud-server-9f09caaaeacb8488a058b956357f363ddfd2fc9e.zip
Activate the primary dialog button on enter if there is a single input
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'core/src')
-rw-r--r--core/src/jquery/ocdialog.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/src/jquery/ocdialog.js b/core/src/jquery/ocdialog.js
index 91466f6fec5..17f466e7cb1 100644
--- a/core/src/jquery/ocdialog.js
+++ b/core/src/jquery/ocdialog.js
@@ -56,6 +56,21 @@ $.widget('oc.ocdialog', {
this.$dialog.append(this.element.detach())
this.element.removeAttr('title').addClass('oc-dialog-content').appendTo(this.$dialog)
+ // Activate the primary button on enter if there is a single input
+ if (self.element.find('input').length === 1) {
+ const $input = self.element.find('input')
+ $input.on('keydown', function(event) {
+ if (event.key === 'Enter') {
+ if (self.$buttonrow) {
+ const $button = self.$buttonrow.find('button.primary')
+ if ($button && !$button.prop('disabled')) {
+ $button.click()
+ }
+ }
+ }
+ })
+ }
+
this.$dialog.css({
display: 'inline-block',
position: 'fixed',