Skip to content

Commit

Permalink
Merge branch 'feat/autorefresh-fields' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Dec 3, 2024
2 parents ef0f34b + c21c73b commit b2e9cf7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/widgets/views/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
useRef,
useContext,
useCallback,
useMemo,
} from "react";
import { Form as FormOoui, parseContext } from "@gisce/ooui";
import {
Expand Down Expand Up @@ -253,6 +254,18 @@ function Form(props: FormProps, ref: any) {
const getCurrentId = useCallback(() => {
return id || createdId.current;
}, [id]);
const [refId, setRefId] = useState(() => createdId.current);

useEffect(() => {
if (createdId.current !== refId) {
setRefId(createdId.current);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [createdId.current]);

const currentId = useMemo(() => {
return id || refId;
}, [id, refId]);

function getFields() {
return fields;
Expand Down Expand Up @@ -1087,7 +1100,7 @@ function Form(props: FormProps, ref: any) {

const { pause, resume } = useAutorefreshableFields({
model,
id,
id: currentId,
context: parentContext,
autorefreshableFields: formOoui?.autorefreshableFields,
fieldDefs: fields,
Expand Down

0 comments on commit b2e9cf7

Please sign in to comment.