fix: report-edit

This commit is contained in:
João Gustavo 2025-11-27 21:07:27 -03:00
parent 6c0a6f7367
commit 621817e963

View File

@ -89,13 +89,6 @@ export default function EditarLaudoPage() {
return () => clearTimeout(timeoutId);
}, [content, campos, laudoId]);
// Sincronizar conteúdo com o editor
useEffect(() => {
if (editorRef.current && content) {
editorRef.current.innerHTML = content;
}
}, [content]);
// Função para trocar de aba salvando conteúdo antes
const handleTabChange = (newTab: string) => {
// Salvar conteúdo do editor antes de trocar
@ -103,16 +96,19 @@ export default function EditarLaudoPage() {
const editorContent = editorRef.current.innerHTML;
setContent(editorContent);
}
// Se estiver voltando para o editor, restaurar conteúdo
if (newTab === 'editor') {
setTimeout(() => {
if (editorRef.current && content) {
editorRef.current.innerHTML = content;
}
}, 0);
}
setActiveTab(newTab);
};
// Restaurar conteúdo quando volta para a aba editor
useEffect(() => {
if (activeTab === 'editor' && editorRef.current && content) {
editorRef.current.innerHTML = content;
}
}, [activeTab]);
// Atualizar formatações ativas ao mudar seleção
useEffect(() => {
const updateFormats = () => {