linguabot commited on
Commit
4861cf5
·
verified ·
1 Parent(s): 2b01575

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. client/src/pages/TutorialTasks.tsx +15 -57
client/src/pages/TutorialTasks.tsx CHANGED
@@ -931,75 +931,33 @@ const TutorialTasks: React.FC = () => {
931
  const preCardH = cardEl ? cardEl.getBoundingClientRect().height : 0;
932
  const preHeight = preGridH > 0 ? preGridH : (preContH > 0 ? preContH : preCardH);
933
  try { console.log('[Trace] Submit:preHeights', { taskId, preGridH, preContH, preCardH, chosen: preHeight }); } catch {}
934
- if (preHeight > 0) setSpacerHeights(prev => ({ ...prev, [taskId]: preHeight }));
935
  lastPreHeightRef.current[taskId] = preHeight;
936
  disableCompensationRef.current.add(taskId);
937
  withPreservedCardOffset(taskId, () => {
938
  React.startTransition(() => {
939
  setTranslationText({ ...translationText, [taskId]: '' });
940
  setSelectedGroups({ ...selectedGroups, [taskId]: 0 });
941
- // Narrow refetch: only this task's submissions
 
 
942
  pendingUnlocksRef.current.add(taskId);
943
  api.get(`/api/submissions/by-source/${taskId}`).then(r => {
944
  const list = (r.data && r.data.submissions) || [];
945
  setUserSubmissions(prev => ({ ...prev, [taskId]: list }));
946
- // Release spacer one frame after list update to avoid jump
947
- requestAnimationFrame(() => {
948
- setSpacerHeights(prev => ({ ...prev, [taskId]: 0 }));
949
- const afterGrid = submissionsGridRefs.current[taskId];
950
- const afterCont = submissionsContainerRefs.current[taskId];
951
- const afterCard = cardRefs.current[taskId];
952
- const afterGridH = afterGrid ? afterGrid.getBoundingClientRect().height : 0;
953
- const afterContH = afterCont ? afterCont.getBoundingClientRect().height : 0;
954
- const afterCardH = afterCard ? afterCard.getBoundingClientRect().height : 0;
955
- const afterH = afterGridH > 0 ? afterGridH : (afterContH > 0 ? afterContH : afterCardH);
956
- try { console.log('[Trace] Submit:unlockGate', { taskId, preHeight, afterH, afterGridH, afterContH, afterCardH }); } catch {}
957
- const doUnlock = () => {
958
- unlockListHeight();
959
- unlockCardHeightById(taskId);
960
- unlockGridHeightById(taskId);
961
- unlockContainerHeightById(taskId);
962
- pendingUnlocksRef.current.delete(taskId);
963
- if (isSafari) { unfreezeScroll(); }
964
- disableCompensationRef.current.delete(taskId);
965
- };
966
- if ((afterH || 0) > 0 && (preHeight || 0) > 0 && Math.abs(afterH - preHeight) <= 1) {
967
- doUnlock();
968
- } else {
969
- // Gate one more frame for Safari layout to settle
970
- requestAnimationFrame(() => {
971
- const afterGrid2 = submissionsGridRefs.current[taskId];
972
- const afterCont2 = submissionsContainerRefs.current[taskId];
973
- const afterCard2 = cardRefs.current[taskId];
974
- const afterGridH2 = afterGrid2 ? afterGrid2.getBoundingClientRect().height : 0;
975
- const afterContH2 = afterCont2 ? afterCont2.getBoundingClientRect().height : 0;
976
- const afterCardH2 = afterCard2 ? afterCard2.getBoundingClientRect().height : 0;
977
- const afterH2 = afterGridH2 > 0 ? afterGridH2 : (afterContH2 > 0 ? afterContH2 : afterCardH2);
978
- try { console.log('[Trace] Submit:unlockGate2', { taskId, preHeight, afterH2, afterGridH2, afterContH2, afterCardH2 }); } catch {}
979
- if ((afterH2 || 0) > 0 && (preHeight || 0) > 0 && Math.abs(afterH2 - preHeight) <= 1) {
980
- doUnlock();
981
- } else {
982
- // Fallback: still unlock to prevent permanent lock, but note trace
983
- try { console.log('[Trace] Submit:unlockFallback', { taskId, preHeight, afterH, afterH2 }); } catch {}
984
- doUnlock();
985
- }
986
- });
987
- }
988
- });
989
  }).catch(() => {
990
- requestAnimationFrame(() => {
991
- setSpacerHeights(prev => ({ ...prev, [taskId]: 0 }));
992
- // On error, unlock now
993
- unlockListHeight();
994
- unlockCardHeightById(taskId);
995
- unlockGridHeightById(taskId);
996
- unlockContainerHeightById(taskId);
997
- pendingUnlocksRef.current.delete(taskId);
998
- if (isSafari) { unfreezeScroll(); }
999
- disableCompensationRef.current.delete(taskId);
1000
- });
1001
  });
1002
- });
 
 
 
 
 
 
 
 
1003
  });
1004
  } else {
1005
  console.error('[Trace] Submit:Error', response.data);
 
931
  const preCardH = cardEl ? cardEl.getBoundingClientRect().height : 0;
932
  const preHeight = preGridH > 0 ? preGridH : (preContH > 0 ? preContH : preCardH);
933
  try { console.log('[Trace] Submit:preHeights', { taskId, preGridH, preContH, preCardH, chosen: preHeight }); } catch {}
934
+ if (!isSafari && preHeight > 0) setSpacerHeights(prev => ({ ...prev, [taskId]: preHeight }));
935
  lastPreHeightRef.current[taskId] = preHeight;
936
  disableCompensationRef.current.add(taskId);
937
  withPreservedCardOffset(taskId, () => {
938
  React.startTransition(() => {
939
  setTranslationText({ ...translationText, [taskId]: '' });
940
  setSelectedGroups({ ...selectedGroups, [taskId]: 0 });
941
+ });
942
+ if (!isSafari) {
943
+ // Narrow refetch immediately for non-Safari
944
  pendingUnlocksRef.current.add(taskId);
945
  api.get(`/api/submissions/by-source/${taskId}`).then(r => {
946
  const list = (r.data && r.data.submissions) || [];
947
  setUserSubmissions(prev => ({ ...prev, [taskId]: list }));
948
+ requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
949
  }).catch(() => {
950
+ requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
 
 
 
 
 
 
 
 
 
 
951
  });
952
+ } else {
953
+ // Safari: delay refetch until after unlock to avoid visible reflow
954
+ setTimeout(() => {
955
+ api.get(`/api/submissions/by-source/${taskId}`).then(r => {
956
+ const list = (r.data && r.data.submissions) || [];
957
+ setUserSubmissions(prev => ({ ...prev, [taskId]: list }));
958
+ }).catch(() => {});
959
+ }, 300);
960
+ }
961
  });
962
  } else {
963
  console.error('[Trace] Submit:Error', response.data);