Przeglądaj źródła

fix(js): early return from slideDown/slideUp when duration < 1 (#5964)

When duration is zero, setTimeout ordering is unreliable (especially
in Firefox), causing style cleanup to fail. Skip animation entirely
for zero-duration calls, fixing treeview instant-open on page load.

Based on PR #5964 by @Kneemund.

Co-Authored-By: Moritz Mechelk <moritzmechelk@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Aigars Silkalns 1 dzień temu
rodzic
commit
0d4d8577a1

+ 7 - 0
dist/js/adminlte.js

@@ -26,6 +26,10 @@
         }
     };
     const slideUp = (target, duration = 500) => {
+        if (duration <= 1) {
+            target.style.display = 'none';
+            return;
+        }
         target.style.transitionProperty = 'height, margin, padding';
         target.style.transitionDuration = `${duration}ms`;
         target.style.boxSizing = 'border-box';
@@ -57,6 +61,9 @@
             display = 'block';
         }
         target.style.display = display;
+        if (duration <= 1) {
+            return;
+        }
         const height = target.offsetHeight;
         target.style.overflow = 'hidden';
         target.style.height = '0';

Plik diff jest za duży
+ 0 - 0
dist/js/adminlte.js.map


Plik diff jest za duży
+ 0 - 0
dist/js/adminlte.min.js


Plik diff jest za duży
+ 0 - 0
dist/js/adminlte.min.js.map


+ 10 - 0
src/ts/util/index.ts

@@ -48,6 +48,11 @@ const safePropertyAccess = (obj: Record<string, unknown>, property: string): unk
 
 /* SLIDE UP */
 const slideUp = (target: HTMLElement, duration = 500) => {
+  if (duration <= 1) {
+    target.style.display = 'none'
+    return
+  }
+
   target.style.transitionProperty = 'height, margin, padding'
   target.style.transitionDuration = `${duration}ms`
   target.style.boxSizing = 'border-box'
@@ -85,6 +90,11 @@ const slideDown = (target: HTMLElement, duration = 500) => {
   }
 
   target.style.display = display
+
+  if (duration <= 1) {
+    return
+  }
+
   const height = target.offsetHeight
   target.style.overflow = 'hidden'
   target.style.height = '0'

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików