Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -916,26 +916,34 @@ const TutorialTasks: React.FC = () => {
|
|
| 916 |
});
|
| 917 |
|
| 918 |
// Defer state updates and minimal refetch
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 932 |
});
|
| 933 |
-
requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
|
| 934 |
-
}).catch(() => {
|
| 935 |
-
requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
|
| 936 |
});
|
| 937 |
});
|
| 938 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 939 |
} else {
|
| 940 |
console.error('Failed to submit translation:', response.data);
|
| 941 |
}
|
|
@@ -2323,7 +2331,7 @@ const TutorialTasks: React.FC = () => {
|
|
| 2323 |
|
| 2324 |
{/* All Submissions for this Task */}
|
| 2325 |
{userSubmissions[task._id] && userSubmissions[task._id].length > 0 && (
|
| 2326 |
-
<div ref={(el) => { submissionsContainerRefs.current[task._id] = el; }} className="bg-gradient-to-r from-white to-indigo-50 rounded-xl p-6 mb-6 border border-stone-200" style={{ overflowAnchor: 'none' }}>
|
| 2327 |
<div className="flex items-center justify-between mb-4">
|
| 2328 |
<div className="flex items-center space-x-2">
|
| 2329 |
<div className="bg-indigo-100 rounded-full p-1">
|
|
@@ -2350,7 +2358,7 @@ const TutorialTasks: React.FC = () => {
|
|
| 2350 |
expandedSections[task._id]
|
| 2351 |
? 'max-h-none overflow-visible'
|
| 2352 |
: 'max-h-0 overflow-hidden'
|
| 2353 |
-
}`}>
|
| 2354 |
{userSubmissions[task._id].map((submission, index) => (
|
| 2355 |
<div key={submission._id} className="bg-white rounded-lg p-3 border border-stone-200 flex flex-col justify-between h-full">
|
| 2356 |
<div className="flex items-center justify-between mb-2">
|
|
|
|
| 916 |
});
|
| 917 |
|
| 918 |
// Defer state updates and minimal refetch
|
| 919 |
+
if (!isSafari) {
|
| 920 |
+
// Measure grid height and set spacer before refetch to keep layout height constant
|
| 921 |
+
const gridEl = submissionsGridRefs.current[taskId];
|
| 922 |
+
const gridHeight = gridEl ? gridEl.getBoundingClientRect().height : 0;
|
| 923 |
+
if (gridHeight > 0) setSpacerHeights(prev => ({ ...prev, [taskId]: gridHeight }));
|
| 924 |
+
withPreservedCardOffset(taskId, () => {
|
| 925 |
+
React.startTransition(() => {
|
| 926 |
+
setTranslationText({ ...translationText, [taskId]: '' });
|
| 927 |
+
setSelectedGroups({ ...selectedGroups, [taskId]: 0 });
|
| 928 |
+
// Narrow refetch: only this task's submissions. Build off-DOM then swap in one commit
|
| 929 |
+
api.get(`/api/submissions/by-source/${taskId}`).then(r => {
|
| 930 |
+
const list = (r.data && r.data.submissions) || [];
|
| 931 |
+
flushSync(() => {
|
| 932 |
+
setUserSubmissions(prev => ({ ...prev, [taskId]: list }));
|
| 933 |
+
});
|
| 934 |
+
requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
|
| 935 |
+
}).catch(() => {
|
| 936 |
+
requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
|
| 937 |
});
|
|
|
|
|
|
|
|
|
|
| 938 |
});
|
| 939 |
});
|
| 940 |
+
} else {
|
| 941 |
+
// Safari: skip refetch to avoid extra reflow; just clear local fields
|
| 942 |
+
React.startTransition(() => {
|
| 943 |
+
setTranslationText({ ...translationText, [taskId]: '' });
|
| 944 |
+
setSelectedGroups({ ...selectedGroups, [taskId]: 0 });
|
| 945 |
+
});
|
| 946 |
+
}
|
| 947 |
} else {
|
| 948 |
console.error('Failed to submit translation:', response.data);
|
| 949 |
}
|
|
|
|
| 2331 |
|
| 2332 |
{/* All Submissions for this Task */}
|
| 2333 |
{userSubmissions[task._id] && userSubmissions[task._id].length > 0 && (
|
| 2334 |
+
<div ref={(el) => { submissionsContainerRefs.current[task._id] = el; }} className="bg-gradient-to-r from-white to-indigo-50 rounded-xl p-6 mb-6 border border-stone-200" style={{ overflowAnchor: 'none', overscrollBehavior: 'contain' as any }}>
|
| 2335 |
<div className="flex items-center justify-between mb-4">
|
| 2336 |
<div className="flex items-center space-x-2">
|
| 2337 |
<div className="bg-indigo-100 rounded-full p-1">
|
|
|
|
| 2358 |
expandedSections[task._id]
|
| 2359 |
? 'max-h-none overflow-visible'
|
| 2360 |
: 'max-h-0 overflow-hidden'
|
| 2361 |
+
}`} style={{ overscrollBehavior: 'contain' as any }}>
|
| 2362 |
{userSubmissions[task._id].map((submission, index) => (
|
| 2363 |
<div key={submission._id} className="bg-white rounded-lg p-3 border border-stone-200 flex flex-col justify-between h-full">
|
| 2364 |
<div className="flex items-center justify-between mb-2">
|