diff --git a/core/misc/dialog/dialog.ajax.es6.js b/core/misc/dialog/dialog.ajax.es6.js
index 2a017d29f8a705774d515321d6b7a818c1df4d50..cd1c4708d5a23a906a0d6c946cc6b0a57b0b710f 100644
--- a/core/misc/dialog/dialog.ajax.es6.js
+++ b/core/misc/dialog/dialog.ajax.es6.js
@@ -65,19 +65,7 @@
         '.form-actions input[type=submit], .form-actions a.button',
       );
       $buttons.each(function() {
-        // Hidden form buttons need special attention. For browser consistency,
-        // the button needs to be "visible" in order to have the enter key fire
-        // the form submit event. So instead of a simple "hide" or
-        // "display: none", we set its dimensions to zero.
-        // See http://mattsnider.com/how-forms-submit-when-pressing-enter/
-        const $originalButton = $(this).css({
-          display: 'block',
-          width: 0,
-          height: 0,
-          padding: 0,
-          border: 0,
-          overflow: 'hidden',
-        });
+        const $originalButton = $(this).css({ display: 'none' });
         buttons.push({
           text: $originalButton.html() || $originalButton.attr('value'),
           class: $originalButton.attr('class'),
diff --git a/core/misc/dialog/dialog.ajax.js b/core/misc/dialog/dialog.ajax.js
index de1d3c921977e8460cc2a114046f29fd0ce8a889..3f01d4939496b18cc89805da39f02f6146f56611 100644
--- a/core/misc/dialog/dialog.ajax.js
+++ b/core/misc/dialog/dialog.ajax.js
@@ -38,14 +38,7 @@
       var buttons = [];
       var $buttons = $dialog.find('.form-actions input[type=submit], .form-actions a.button');
       $buttons.each(function () {
-        var $originalButton = $(this).css({
-          display: 'block',
-          width: 0,
-          height: 0,
-          padding: 0,
-          border: 0,
-          overflow: 'hidden'
-        });
+        var $originalButton = $(this).css({ display: 'none' });
         buttons.push({
           text: $originalButton.html() || $originalButton.attr('value'),
           class: $originalButton.attr('class'),
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php
index 26bdd185e6c1ae73579c9238db47fd8e0e59c63b..b0c655190d88c316ae9027012a992db52cbfa755 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php
@@ -140,6 +140,26 @@ public function testDialog() {
     $preview = $form_dialog->findButton('Preview');
     $this->assertNotNull($preview, 'The dialog contains a "Preview" button.');
 
+    // When a form with submit inputs is in a dialog, the form's submit inputs
+    // are copied to the dialog buttonpane as buttons. The originals should have
+    // their styles set to display: none.
+    $hidden_buttons = $this->getSession()->getPage()->findAll('css', '.ajax-test-form [type="submit"]');
+    $this->assertCount(2, $hidden_buttons);
+    $hidden_button_text = [];
+    foreach ($hidden_buttons as $button) {
+      $styles = $button->getAttribute('style');
+      $this->assertTrue((stripos($styles, 'display: none;') !== FALSE));
+      $hidden_button_text[] = $button->getAttribute('value');
+    }
+
+    // The copied buttons should have the same text as the submit inputs they
+    // were copied from.
+    $moved_to_buttonpane_buttons = $this->getSession()->getPage()->findAll('css', '.ui-dialog-buttonpane button');
+    $this->assertCount(2, $moved_to_buttonpane_buttons);
+    foreach ($moved_to_buttonpane_buttons as $key => $button) {
+      $this->assertEqual($button->getText(), $hidden_button_text[$key]);
+    }
+
     // Reset: close the form.
     $form_dialog->findButton('Close')->press();