flow-builder icon indicating copy to clipboard operation
flow-builder copied to clipboard

Getting the current position (index) of the clicked "add node button"

Open rMousali opened this issue 1 year ago • 1 comments

Hello @lixiao1022 I have created a customPoperComponent const CustomPopoverComponent = ({ visible, onVisibleChange, overlayClassName, placement, trigger, content,

children,
...props

}) => { const [isOpen, setOpen] = useState(false);

return (
  <>
    <div
      className={overlayClassName}
      style={{ cursor: "pointer" }}
      onClick={() => setOpen(true)}
    >
      <Icon name="Plus" size={32} isOnclick />
    </div>
    <Modal open={isOpen} footer={[]} onCancel={() => setOpen(false)} width={800} size="lg">
      <StyledModalBody>{content}</StyledModalBody>
    </Modal>
  </>
);

};

When I click on the icon to trigger my modal. I would like to know the position.

My main goal is I would like to render different options when the node before it is start, or different type.

Thanks for the help.

rMousali avatar Mar 23 '24 08:03 rMousali

Hello @lixiao1022 I have created a customPoperComponent const CustomPopoverComponent = ({ visible, onVisibleChange, overlayClassName, placement, trigger, content,

children,
...props

}) => { const [isOpen, setOpen] = useState(false);

return (
  <>
    <div
      className={overlayClassName}
      style={{ cursor: "pointer" }}
      onClick={() => setOpen(true)}
    >
      <Icon name="Plus" size={32} isOnclick />
    </div>
    <Modal open={isOpen} footer={[]} onCancel={() => setOpen(false)} width={800} size="lg">
      <StyledModalBody>{content}</StyledModalBody>
    </Modal>
  </>
);

};

When I click on the icon to trigger my modal. I would like to know the position.

My main goal is I would like to render different options when the node before it is start, or different type.

Thanks for the help.

Please try to use NodeContext in your CustomPopoverComponent, you can get the type of current node. For example:

const node = useContext(NodeContext);

const { type } = node;

lixiao1022 avatar Mar 26 '24 06:03 lixiao1022