Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -2484,6 +2484,15 @@ const TranslationSection: React.FC<{
|
|
| 2484 |
const [localGroup, setLocalGroup] = React.useState<number | ''>(selectedGroup || '');
|
| 2485 |
React.useEffect(() => { setLocalText(translation || ''); }, [taskId]);
|
| 2486 |
React.useEffect(() => { setLocalGroup(selectedGroup || ''); }, [taskId, selectedGroup]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2487 |
const wrapSelection = (wrapper: '**' | '*') => {
|
| 2488 |
const el = document.getElementById(`tutorial-translation-${taskId}`) as HTMLTextAreaElement | null;
|
| 2489 |
const current = localText || '';
|
|
@@ -2556,9 +2565,12 @@ const TranslationSection: React.FC<{
|
|
| 2556 |
placeholder="Enter your group's translation here..."
|
| 2557 |
/>
|
| 2558 |
<button
|
| 2559 |
-
|
|
|
|
|
|
|
| 2560 |
disabled={submitting}
|
| 2561 |
className="relative inline-flex items-center justify-center gap-2 px-4 py-2 rounded-2xl text-sm font-medium text-white ring-1 ring-inset ring-white/50 backdrop-blur-md backdrop-brightness-110 backdrop-saturate-150 shadow-[inset_0_1px_0_rgba(255,255,255,0.6),inset_0_-1px_0_rgba(0,0,0,0.12)] bg-sky-600/70 disabled:bg-gray-400 mt-2"
|
|
|
|
| 2562 |
>
|
| 2563 |
{submitting ? (
|
| 2564 |
<>
|
|
|
|
| 2484 |
const [localGroup, setLocalGroup] = React.useState<number | ''>(selectedGroup || '');
|
| 2485 |
React.useEffect(() => { setLocalText(translation || ''); }, [taskId]);
|
| 2486 |
React.useEffect(() => { setLocalGroup(selectedGroup || ''); }, [taskId, selectedGroup]);
|
| 2487 |
+
const isSafariEnv = typeof navigator !== 'undefined' && /Safari\//.test(navigator.userAgent) && !/Chrome\//.test(navigator.userAgent) && !/CriOS\//.test(navigator.userAgent);
|
| 2488 |
+
const submitTriggeredRef = React.useRef(false);
|
| 2489 |
+
const triggerSubmitOnce = React.useCallback((e?: React.SyntheticEvent) => {
|
| 2490 |
+
if (submitTriggeredRef.current) { e?.preventDefault?.(); return; }
|
| 2491 |
+
submitTriggeredRef.current = true;
|
| 2492 |
+
if (localGroup) onSubmit(localText, localGroup as number);
|
| 2493 |
+
// Small cooldown to avoid duplicate fire from click after pointerdown
|
| 2494 |
+
setTimeout(() => { submitTriggeredRef.current = false; }, 400);
|
| 2495 |
+
}, [localText, localGroup, onSubmit]);
|
| 2496 |
const wrapSelection = (wrapper: '**' | '*') => {
|
| 2497 |
const el = document.getElementById(`tutorial-translation-${taskId}`) as HTMLTextAreaElement | null;
|
| 2498 |
const current = localText || '';
|
|
|
|
| 2565 |
placeholder="Enter your group's translation here..."
|
| 2566 |
/>
|
| 2567 |
<button
|
| 2568 |
+
type="button"
|
| 2569 |
+
onClick={!isSafariEnv ? (e) => { e.preventDefault(); triggerSubmitOnce(e); } : undefined}
|
| 2570 |
+
onPointerDown={isSafariEnv ? (e) => { e.preventDefault(); triggerSubmitOnce(e as unknown as React.SyntheticEvent); } : undefined}
|
| 2571 |
disabled={submitting}
|
| 2572 |
className="relative inline-flex items-center justify-center gap-2 px-4 py-2 rounded-2xl text-sm font-medium text-white ring-1 ring-inset ring-white/50 backdrop-blur-md backdrop-brightness-110 backdrop-saturate-150 shadow-[inset_0_1px_0_rgba(255,255,255,0.6),inset_0_-1px_0_rgba(0,0,0,0.12)] bg-sky-600/70 disabled:bg-gray-400 mt-2"
|
| 2573 |
+
style={{ touchAction: 'manipulation' as any }}
|
| 2574 |
>
|
| 2575 |
{submitting ? (
|
| 2576 |
<>
|