react-flow-chart icon indicating copy to clipboard operation
react-flow-chart copied to clipboard

Dynamic node height problem on 0.0.14

Open basyusuf opened this issue 5 years ago • 7 comments

Node style

const DefaultBox = styled.div`
  position: absolute;
  padding: 2px 2px;
  width:250px;
  background: white;
  color: black;
  border-radius: 3px;
  border:1px solid white;
  height:auto;
  border-color:${props => props.error?"red":"white"}
  -webkit-box-shadow: 0px 0px 7px 1px rgba(120,120,120,0.42);
  -moz-box-shadow: 0px 0px 7px 1px rgba(120,120,120,0.42);
  box-shadow: 0px 0px 7px 1px rgba(120,120,120,0.42);
`

Custom Node

<DefaultBox ref={ref} {...otherProps} error={this.props.error} key={node.id}>
        <BoxContent>
          {node.text}
          {children}
        </BoxContent>
</DefaultBox>

When Node is like this, it goes into space.The node is getting too long.I try max-height but it didn't help. Does anyone have any solutions?

basyusuf avatar Jul 10 '20 13:07 basyusuf

In the 0.0.14 version, if you have a custom Node component and you don't set a fixed height, the node grows uncontrolled.

Here you can find an example: https://codesandbox.io/s/show-arrow-head-pqdck?file=/src/index.js

@basyusuf I didn't find a way to solve this unless of adding a fixed height, like: height: 150px :/

georginaso avatar Jul 21 '20 14:07 georginaso

I am looking for a solution to the dynamic height problem, the fixed height is not the solution.

basyusuf avatar Jul 27 '20 07:07 basyusuf

I think that the padding is causing the wrong behaviour, try with this basic CustomNode:

const CustomNode = styled.div`
  position: absolute;
  -webkit-transition: 0.3s ease box-shadow, 0.3s ease margin-top;
  transition: 0.3s ease box-shadow, 0.3s ease margin-top;
  background: white;
  border-radius: 4px;
  min-width: 200px;
`;

In my case, I have moved the padding that I had in the CustomNode component and I put it in the CustomNodeInner outer div.

georginaso avatar Aug 20 '20 07:08 georginaso

having the same issue with Custom Nodes, @basyusuf found any workarounds? @georginaso both padding and fixed-height solutions are not working for me.

https://mrblenny.github.io/react-flow-chart/index.html?path=/story/sidebar--drag-and-drop

the storybook demo has same behavior once you zoom in and then drag and drop. the infinite height growth seems to stop once I zoom out, could be related to zoom somehow?

tahmid-shahriar-lincx avatar Oct 13 '20 23:10 tahmid-shahriar-lincx

@tahmid-shahriar-lincx are you using a custom Node and NodeInner?

georginaso avatar Oct 14 '20 12:10 georginaso

@georginaso yeap

tahmid-shahriar-lincx avatar Oct 14 '20 16:10 tahmid-shahriar-lincx

setting maxScale to 0.9 seems to stop this uncontrollable height growth, but can't zoom in past 0.9 scale

config={{
    zoom: {
        maxScale: 0.9,
        minScale: 0.1
     }
}}

tahmid-shahriar-lincx avatar Oct 14 '20 17:10 tahmid-shahriar-lincx