mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-11-15 17:21:38 +03:00
B: Fix editor modified status
This commit is contained in:
parent
12584e413b
commit
4f03f048aa
|
|
@ -1,7 +1,7 @@
|
||||||
'use no memo'; // TODO: remove when react hook forms are compliant with react compiler
|
'use no memo'; // TODO: remove when react hook forms are compliant with react compiler
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useMemo, useRef, useState } from 'react';
|
import { useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { Controller, useForm } from 'react-hook-form';
|
import { Controller, useForm } from 'react-hook-form';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
|
@ -145,6 +145,8 @@ export function FormConstituenta({ disabled, id, toggleReset, schema, activeCst,
|
||||||
setLocalParse(null);
|
setLocalParse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useLayoutEffect(() => setIsModified(false), [activeCst.id, setIsModified]);
|
||||||
|
|
||||||
const prevDirty = useRef(isDirty);
|
const prevDirty = useRef(isDirty);
|
||||||
if (prevDirty.current !== isDirty) {
|
if (prevDirty.current !== isDirty) {
|
||||||
prevDirty.current = isDirty;
|
prevDirty.current = isDirty;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ export function RSTabs({ activeID, activeTab }: RSTabsProps) {
|
||||||
const router = useConceptNavigation();
|
const router = useConceptNavigation();
|
||||||
|
|
||||||
const hideFooter = useAppLayoutStore(state => state.hideFooter);
|
const hideFooter = useAppLayoutStore(state => state.hideFooter);
|
||||||
const isModified = useModificationStore(state => state.isModified);
|
|
||||||
const setIsModified = useModificationStore(state => state.setIsModified);
|
const setIsModified = useModificationStore(state => state.setIsModified);
|
||||||
const { schema, selected, setSelected, deselectAll, navigateRSForm } = useRSEdit();
|
const { schema, selected, setSelected, deselectAll, navigateRSForm } = useRSEdit();
|
||||||
|
|
||||||
|
|
@ -40,10 +39,6 @@ export function RSTabs({ activeID, activeTab }: RSTabsProps) {
|
||||||
const nextNoFooter = activeTab !== RSTabID.CARD;
|
const nextNoFooter = activeTab !== RSTabID.CARD;
|
||||||
hideFooter(nextNoFooter);
|
hideFooter(nextNoFooter);
|
||||||
|
|
||||||
if (isModified) {
|
|
||||||
setIsModified(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (activeTab === RSTabID.CST_EDIT) {
|
if (activeTab === RSTabID.CST_EDIT) {
|
||||||
let nextSelected: number[] = [];
|
let nextSelected: number[] = [];
|
||||||
if (activeID && schema.cstByID.has(activeID)) {
|
if (activeID && schema.cstByID.has(activeID)) {
|
||||||
|
|
@ -65,7 +60,7 @@ export function RSTabs({ activeID, activeTab }: RSTabsProps) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [activeTab, activeID, selected, schema, hideFooter, isModified, setIsModified, setSelected, deselectAll]);
|
}, [activeTab, activeID, selected, schema, hideFooter, setSelected, deselectAll]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
return () => hideFooter(false);
|
return () => hideFooter(false);
|
||||||
|
|
@ -75,6 +70,7 @@ export function RSTabs({ activeID, activeTab }: RSTabsProps) {
|
||||||
if (last === index) {
|
if (last === index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setIsModified(false);
|
||||||
if (event.type == 'keydown') {
|
if (event.type == 'keydown') {
|
||||||
const kbEvent = event as KeyboardEvent;
|
const kbEvent = event as KeyboardEvent;
|
||||||
if (kbEvent.altKey) {
|
if (kbEvent.altKey) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user