Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
fix(DataMapper): Container field open/close doesn't refresh lines
Browse files Browse the repository at this point in the history
Fixes: #47
  • Loading branch information
igarashitm committed Sep 16, 2024
1 parent 99c9356 commit b7c0a4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions packages/ui/src/components/Document/SourceDocument.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocumentNodeData, FieldNodeData, MappingNodeData, NodeData } from '../../models/datamapper/visualization';
import { FunctionComponent, useRef, useState } from 'react';
import { FunctionComponent, useCallback, useRef, useState } from 'react';
import { IDocument } from '../../models/datamapper/document';
import { Label, Split, SplitItem, Title } from '@patternfly/react-core';
import { DocumentActions } from './actions/DocumentActions';
Expand All @@ -24,10 +24,13 @@ type DocumentNodeProps = {
};

export const SourceDocumentNode: FunctionComponent<DocumentNodeProps> = ({ nodeData }) => {
const { getNodeReference, reloadNodeReferences, setNodeReference } = useCanvas();
const [collapsed, setCollapsed] = useState(false);
const onClick = () => {

const onClick = useCallback(() => {
setCollapsed(!collapsed);
};
reloadNodeReferences();
}, [collapsed, reloadNodeReferences]);

const isDocument = nodeData instanceof DocumentNodeData;
const children = VisualizationService.generateNodeDataChildren(nodeData);
Expand All @@ -37,7 +40,6 @@ export const SourceDocumentNode: FunctionComponent<DocumentNodeProps> = ({ nodeD

const headerRef = useRef<HTMLDivElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
const { getNodeReference, setNodeReference } = useCanvas();
const nodeReference = useRef<NodeReference>({
get headerRef() {
return headerRef.current;
Expand Down
8 changes: 5 additions & 3 deletions packages/ui/src/components/Document/TargetDocument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ type DocumentNodeProps = {
};

const TargetDocumentNode: FunctionComponent<DocumentNodeProps> = ({ nodeData }) => {
const { getNodeReference, reloadNodeReferences, setNodeReference } = useCanvas();
const [collapsed, setCollapsed] = useState(false);
const onClick = () => {

const onClick = useCallback(() => {
setCollapsed(!collapsed);
};
reloadNodeReferences();
}, [collapsed, reloadNodeReferences]);

const isDocument = VisualizationService.isDocumentNode(nodeData);
const isPrimitive = VisualizationService.isPrimitiveDocumentNode(nodeData);
Expand All @@ -42,7 +45,6 @@ const TargetDocumentNode: FunctionComponent<DocumentNodeProps> = ({ nodeData })

const headerRef = useRef<HTMLDivElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
const { getNodeReference, setNodeReference } = useCanvas();
const nodeReference = useRef<NodeReference>({
get headerRef() {
return headerRef.current;
Expand Down

0 comments on commit b7c0a4d

Please sign in to comment.