Sfoglia il codice sorgente

Fix click.away regression (#2084)

Simone Todaro 3 anni fa
parent
commit
53b087e084
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  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