Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -717,7 +717,9 @@ const TutorialTasks: React.FC = () => {
|
|
| 717 |
}
|
| 718 |
|
| 719 |
try {
|
| 720 |
-
|
|
|
|
|
|
|
| 721 |
const user = JSON.parse(localStorage.getItem('user') || '{}');
|
| 722 |
const response = await api.post('/api/submissions', {
|
| 723 |
sourceTextId: taskId,
|
|
@@ -731,11 +733,13 @@ const TutorialTasks: React.FC = () => {
|
|
| 731 |
const result = response.data;
|
| 732 |
console.log('Submission created successfully:', result);
|
| 733 |
|
| 734 |
-
// Defer all state updates to prevent UI jumping
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
|
|
|
|
|
|
| 739 |
});
|
| 740 |
} else {
|
| 741 |
console.error('Failed to submit translation:', response.data);
|
|
@@ -744,7 +748,9 @@ const TutorialTasks: React.FC = () => {
|
|
| 744 |
console.error('Error submitting translation:', error);
|
| 745 |
|
| 746 |
} finally {
|
| 747 |
-
|
|
|
|
|
|
|
| 748 |
}
|
| 749 |
};
|
| 750 |
|
|
@@ -794,9 +800,11 @@ const TutorialTasks: React.FC = () => {
|
|
| 794 |
|
| 795 |
if (response.status === 200) {
|
| 796 |
|
| 797 |
-
// Defer refetch to prevent UI jumping
|
| 798 |
-
|
| 799 |
-
|
|
|
|
|
|
|
| 800 |
});
|
| 801 |
} else {
|
| 802 |
|
|
|
|
| 717 |
}
|
| 718 |
|
| 719 |
try {
|
| 720 |
+
withPreservedScroll.current?.(() => {
|
| 721 |
+
setSubmitting({ ...submitting, [taskId]: true });
|
| 722 |
+
});
|
| 723 |
const user = JSON.parse(localStorage.getItem('user') || '{}');
|
| 724 |
const response = await api.post('/api/submissions', {
|
| 725 |
sourceTextId: taskId,
|
|
|
|
| 733 |
const result = response.data;
|
| 734 |
console.log('Submission created successfully:', result);
|
| 735 |
|
| 736 |
+
// Defer all state updates and preserve scroll to prevent UI jumping
|
| 737 |
+
withPreservedScroll.current?.(() => {
|
| 738 |
+
React.startTransition(() => {
|
| 739 |
+
setTranslationText({ ...translationText, [taskId]: '' });
|
| 740 |
+
setSelectedGroups({ ...selectedGroups, [taskId]: 0 });
|
| 741 |
+
fetchUserSubmissions(tutorialTasks);
|
| 742 |
+
});
|
| 743 |
});
|
| 744 |
} else {
|
| 745 |
console.error('Failed to submit translation:', response.data);
|
|
|
|
| 748 |
console.error('Error submitting translation:', error);
|
| 749 |
|
| 750 |
} finally {
|
| 751 |
+
withPreservedScroll.current?.(() => {
|
| 752 |
+
setSubmitting({ ...submitting, [taskId]: false });
|
| 753 |
+
});
|
| 754 |
}
|
| 755 |
};
|
| 756 |
|
|
|
|
| 800 |
|
| 801 |
if (response.status === 200) {
|
| 802 |
|
| 803 |
+
// Defer refetch to prevent UI jumping and preserve scroll around DOM updates
|
| 804 |
+
withPreservedScroll.current?.(() => {
|
| 805 |
+
React.startTransition(() => {
|
| 806 |
+
fetchUserSubmissions(tutorialTasks);
|
| 807 |
+
});
|
| 808 |
});
|
| 809 |
} else {
|
| 810 |
|