1
0
mirror of https://github.com/alexandrev/xslt-lab.git synced 2026-09-16 18:23:16 +00:00

Fix stickybox not loading: separate effect triggered by showResultPane

The stickybox slot only mounts after the first transform (showResultPane=true).
Split into two effects: header loads on ethicalAdsReady, sticky loads when
showResultPane changes and its ref is available.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
alexandrev-tibco
2026-05-05 14:28:08 +02:00
parent 9a1b9e7108
commit a480a05e03
+23 -14
View File
@@ -1500,25 +1500,34 @@ export default function App() {
};
}, [ethicalAdsEnabled]);
const loadEaSlot = useCallback((ref) => {
try {
if (ref.current && window.ethicalads) {
ref.current.innerHTML = "";
window.ethicalads.load(ref.current);
}
} catch {}
}, []);
// Load header slot when EA is ready
useEffect(() => {
if (!ethicalAdsEnabled || !ethicalAdsReady) return;
const loadSlot = (ref) => {
try {
if (ref.current) {
ref.current.innerHTML = "";
window.ethicalads?.load(ref.current);
}
} catch {}
};
loadSlot(ethicalSlotRef);
loadSlot(ethicalStickyRef);
// Retry if slots still empty after 1.5s
loadEaSlot(ethicalSlotRef);
const t = window.setTimeout(() => {
if (ethicalSlotRef.current && !ethicalSlotRef.current.children.length) loadSlot(ethicalSlotRef);
if (ethicalStickyRef.current && !ethicalStickyRef.current.children.length) loadSlot(ethicalStickyRef);
if (ethicalSlotRef.current && !ethicalSlotRef.current.children.length) loadEaSlot(ethicalSlotRef);
}, 1500);
return () => window.clearTimeout(t);
}, [ethicalAdsEnabled, ethicalAdsReady]);
}, [ethicalAdsEnabled, ethicalAdsReady, loadEaSlot]);
// Load stickybox when its ref mounts (showResultPane becomes true after first transform)
useEffect(() => {
if (!ethicalAdsEnabled || !ethicalAdsReady || !ethicalStickyRef.current) return;
loadEaSlot(ethicalStickyRef);
const t = window.setTimeout(() => {
if (ethicalStickyRef.current && !ethicalStickyRef.current.children.length) loadEaSlot(ethicalStickyRef);
}, 1500);
return () => window.clearTimeout(t);
}, [ethicalAdsEnabled, ethicalAdsReady, showResultPane, loadEaSlot]);
return (