Browse Source

Fix click.away regression (#2084)

Simone Todaro 3 năm trước cách đây
mục cha
commit
53b087e084
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  1. 4 1
      packages/alpinejs/src/directives/x-transition.js

+ 4 - 1
packages/alpinejs/src/directives/x-transition.js

@@ -125,7 +125,10 @@ function registerTransitionObject(el, setFunction, defaultValue = {}) {
 }
 
 window.Element.prototype._x_toggleAndCascadeWithTransitions = function (el, value, show, hide) {
-    let clickAwayCompatibleShow = show
+    // We are wrapping this function in a setTimeout here to prevent
+    // a race condition from happening where elements that have a
+    // @click.away always view themselves as shown on the page.
+    let clickAwayCompatibleShow = () => setTimeout(show)
 
     if (value) {
         el._x_transition