ソースを参照

Fix click.away regression (#2084)

Simone Todaro 3 年 前
コミット
53b087e084
1 ファイル変更4 行追加1 行削除
  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) {
 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) {
     if (value) {
         el._x_transition
         el._x_transition