Caleb Porzio 2 лет назад
Родитель
Сommit
bc453d245c

+ 1 - 1
packages/ui/src/disclosure.js

@@ -64,7 +64,7 @@ function handleButton(el, Alpine) {
         // Required for firefox, event.preventDefault() in handleKeyDown for
         // the Space key doesn't cancel the handleKeyUp, which in turn
         // triggers a *click*.
-        '@keyup.space.prevent'() { this.$data.__toggle() },
+        '@keyup.space.prevent'() {},
     })
 }
 

+ 23 - 0
tests/cypress/integration/plugins/ui/disclosure.spec.js

@@ -77,3 +77,26 @@ test('can set a default open state',
         get('[panel]').should(notBeVisible())
     },
 )
+
+test.only('it toggles using the space key',
+    [html`
+        <div x-data x-disclosure>
+            <button trigger x-disclosure:button>Trigger</button>
+
+            <div x-disclosure:panel panel>
+                Content
+
+                <button close-button type="button" @click="$disclosure.close()">Close</button>
+            </div>
+        </div>
+    `],
+    ({ get }) => {
+        get('[panel]').should(notBeVisible())
+        get('[trigger]').click()
+        get('[panel]').should(beVisible())
+        get('[trigger]').type(' ')
+        get('[panel]').should(notBeVisible())
+        get('[trigger]').type(' ')
+        get('[panel]').should(beVisible())
+    },
+)