Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -78,6 +78,8 @@ const TutorialTasks: React.FC = () => {
|
|
| 78 |
const submissionsContainerRefs = useRef<{[key: string]: HTMLDivElement | null}>({});
|
| 79 |
const withPreservedScroll = useRef<(fn: () => void) => void>();
|
| 80 |
const pendingUnlocksRef = useRef<Set<string>>(new Set());
|
|
|
|
|
|
|
| 81 |
|
| 82 |
const setGlobalAnchorDisabled = (disabled: boolean) => {
|
| 83 |
try {
|
|
@@ -185,6 +187,14 @@ const TutorialTasks: React.FC = () => {
|
|
| 185 |
fn();
|
| 186 |
return;
|
| 187 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
const el = cardRefs.current[taskId];
|
| 189 |
const topBefore = el ? el.getBoundingClientRect().top : null;
|
| 190 |
const scrollYBefore = window.scrollY;
|
|
@@ -910,6 +920,8 @@ const TutorialTasks: React.FC = () => {
|
|
| 910 |
const preContH = containerEl ? containerEl.getBoundingClientRect().height : 0;
|
| 911 |
const preHeight = preGridH > 0 ? preGridH : preContH;
|
| 912 |
if (preHeight > 0) setSpacerHeights(prev => ({ ...prev, [taskId]: preHeight }));
|
|
|
|
|
|
|
| 913 |
withPreservedCardOffset(taskId, () => {
|
| 914 |
React.startTransition(() => {
|
| 915 |
setTranslationText({ ...translationText, [taskId]: '' });
|
|
@@ -934,8 +946,9 @@ const TutorialTasks: React.FC = () => {
|
|
| 934 |
unlockGridHeightById(taskId);
|
| 935 |
pendingUnlocksRef.current.delete(taskId);
|
| 936 |
if (isSafari) { unfreezeScroll(); }
|
|
|
|
| 937 |
};
|
| 938 |
-
if (
|
| 939 |
doUnlock();
|
| 940 |
} else {
|
| 941 |
// Gate one more frame for Safari layout to settle
|
|
@@ -946,7 +959,13 @@ const TutorialTasks: React.FC = () => {
|
|
| 946 |
const afterContH2 = afterCont2 ? afterCont2.getBoundingClientRect().height : 0;
|
| 947 |
const afterH2 = afterGridH2 > 0 ? afterGridH2 : afterContH2;
|
| 948 |
try { console.log('[Trace] Submit:unlockGate2', { taskId, preHeight, afterH2 }); } catch {}
|
| 949 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 950 |
});
|
| 951 |
}
|
| 952 |
});
|
|
@@ -959,6 +978,7 @@ const TutorialTasks: React.FC = () => {
|
|
| 959 |
unlockGridHeightById(taskId);
|
| 960 |
pendingUnlocksRef.current.delete(taskId);
|
| 961 |
if (isSafari) { unfreezeScroll(); }
|
|
|
|
| 962 |
});
|
| 963 |
});
|
| 964 |
});
|
|
|
|
| 78 |
const submissionsContainerRefs = useRef<{[key: string]: HTMLDivElement | null}>({});
|
| 79 |
const withPreservedScroll = useRef<(fn: () => void) => void>();
|
| 80 |
const pendingUnlocksRef = useRef<Set<string>>(new Set());
|
| 81 |
+
const lastPreHeightRef = useRef<{[key: string]: number}>({});
|
| 82 |
+
const disableCompensationRef = useRef<Set<string>>(new Set());
|
| 83 |
|
| 84 |
const setGlobalAnchorDisabled = (disabled: boolean) => {
|
| 85 |
try {
|
|
|
|
| 187 |
fn();
|
| 188 |
return;
|
| 189 |
}
|
| 190 |
+
if (disableCompensationRef.current.has(taskId)) {
|
| 191 |
+
fn();
|
| 192 |
+
return;
|
| 193 |
+
}
|
| 194 |
+
if ((lastPreHeightRef.current[taskId] || 0) === 0) {
|
| 195 |
+
fn();
|
| 196 |
+
return;
|
| 197 |
+
}
|
| 198 |
const el = cardRefs.current[taskId];
|
| 199 |
const topBefore = el ? el.getBoundingClientRect().top : null;
|
| 200 |
const scrollYBefore = window.scrollY;
|
|
|
|
| 920 |
const preContH = containerEl ? containerEl.getBoundingClientRect().height : 0;
|
| 921 |
const preHeight = preGridH > 0 ? preGridH : preContH;
|
| 922 |
if (preHeight > 0) setSpacerHeights(prev => ({ ...prev, [taskId]: preHeight }));
|
| 923 |
+
lastPreHeightRef.current[taskId] = preHeight;
|
| 924 |
+
disableCompensationRef.current.add(taskId);
|
| 925 |
withPreservedCardOffset(taskId, () => {
|
| 926 |
React.startTransition(() => {
|
| 927 |
setTranslationText({ ...translationText, [taskId]: '' });
|
|
|
|
| 946 |
unlockGridHeightById(taskId);
|
| 947 |
pendingUnlocksRef.current.delete(taskId);
|
| 948 |
if (isSafari) { unfreezeScroll(); }
|
| 949 |
+
disableCompensationRef.current.delete(taskId);
|
| 950 |
};
|
| 951 |
+
if ((afterH || 0) > 0 && (preHeight || 0) > 0 && Math.abs(afterH - preHeight) <= 1) {
|
| 952 |
doUnlock();
|
| 953 |
} else {
|
| 954 |
// Gate one more frame for Safari layout to settle
|
|
|
|
| 959 |
const afterContH2 = afterCont2 ? afterCont2.getBoundingClientRect().height : 0;
|
| 960 |
const afterH2 = afterGridH2 > 0 ? afterGridH2 : afterContH2;
|
| 961 |
try { console.log('[Trace] Submit:unlockGate2', { taskId, preHeight, afterH2 }); } catch {}
|
| 962 |
+
if ((afterH2 || 0) > 0 && (afterH || 0) > 0 && Math.abs(afterH2 - afterH) <= 1) {
|
| 963 |
+
doUnlock();
|
| 964 |
+
} else {
|
| 965 |
+
// Fallback: still unlock to prevent permanent lock, but note trace
|
| 966 |
+
try { console.log('[Trace] Submit:unlockFallback', { taskId, preHeight, afterH, afterH2 }); } catch {}
|
| 967 |
+
doUnlock();
|
| 968 |
+
}
|
| 969 |
});
|
| 970 |
}
|
| 971 |
});
|
|
|
|
| 978 |
unlockGridHeightById(taskId);
|
| 979 |
pendingUnlocksRef.current.delete(taskId);
|
| 980 |
if (isSafari) { unfreezeScroll(); }
|
| 981 |
+
disableCompensationRef.current.delete(taskId);
|
| 982 |
});
|
| 983 |
});
|
| 984 |
});
|