linguabot commited on
Commit
4e08c38
·
verified ·
1 Parent(s): 3ee0d07

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. client/src/pages/TutorialTasks.tsx +23 -0
client/src/pages/TutorialTasks.tsx CHANGED
@@ -74,6 +74,23 @@ const TutorialTasks: React.FC = () => {
74
  const listRef = useRef<HTMLDivElement | null>(null);
75
  const withPreservedScroll = useRef<(fn: () => void) => void>();
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  // Initialize scroll preservation helper once
78
  useEffect(() => {
79
  withPreservedScroll.current = (fn: () => void) => {
@@ -717,6 +734,7 @@ const TutorialTasks: React.FC = () => {
717
  }
718
 
719
  try {
 
720
  withPreservedScroll.current?.(() => {
721
  setSubmitting({ ...submitting, [taskId]: true });
722
  });
@@ -751,6 +769,8 @@ const TutorialTasks: React.FC = () => {
751
  withPreservedScroll.current?.(() => {
752
  setSubmitting({ ...submitting, [taskId]: false });
753
  });
 
 
754
  }
755
  };
756
 
@@ -796,6 +816,7 @@ const TutorialTasks: React.FC = () => {
796
 
797
 
798
  try {
 
799
  const response = await api.delete(`/api/submissions/${submissionId}`);
800
 
801
  if (response.status === 200) {
@@ -813,6 +834,8 @@ const TutorialTasks: React.FC = () => {
813
  console.error('Error deleting submission:', error);
814
 
815
  }
 
 
816
  };
817
 
818
  const getStatusIcon = (status: string) => {
 
74
  const listRef = useRef<HTMLDivElement | null>(null);
75
  const withPreservedScroll = useRef<(fn: () => void) => void>();
76
 
77
+ // Minimal, local scroll-stability helpers for submit/delete
78
+ const lockListHeight = () => {
79
+ const el = listRef.current;
80
+ if (!el) return;
81
+ const h = el.getBoundingClientRect().height;
82
+ el.style.minHeight = `${h}px`;
83
+ el.style.height = `${h}px`;
84
+ el.style.overflow = 'hidden';
85
+ };
86
+ const unlockListHeight = () => {
87
+ const el = listRef.current;
88
+ if (!el) return;
89
+ el.style.overflow = '';
90
+ el.style.height = '';
91
+ el.style.minHeight = '';
92
+ };
93
+
94
  // Initialize scroll preservation helper once
95
  useEffect(() => {
96
  withPreservedScroll.current = (fn: () => void) => {
 
734
  }
735
 
736
  try {
737
+ lockListHeight();
738
  withPreservedScroll.current?.(() => {
739
  setSubmitting({ ...submitting, [taskId]: true });
740
  });
 
769
  withPreservedScroll.current?.(() => {
770
  setSubmitting({ ...submitting, [taskId]: false });
771
  });
772
+ // release after a couple frames to let DOM settle
773
+ requestAnimationFrame(() => requestAnimationFrame(unlockListHeight));
774
  }
775
  };
776
 
 
816
 
817
 
818
  try {
819
+ lockListHeight();
820
  const response = await api.delete(`/api/submissions/${submissionId}`);
821
 
822
  if (response.status === 200) {
 
834
  console.error('Error deleting submission:', error);
835
 
836
  }
837
+ // let DOM settle then unlock
838
+ requestAnimationFrame(() => requestAnimationFrame(unlockListHeight));
839
  };
840
 
841
  const getStatusIcon = (status: string) => {