feat: use useUpdateNodeInternals to solve the issue that the newly ad… (#1287)

### What problem does this PR solve?

feat: use useUpdateNodeInternals to solve the issue that the newly added
anchor points cannot be connected. #918

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu 2024-06-27 11:29:46 +08:00 committed by GitHub
parent 038ca8c0ea
commit a943aefa4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
import { CloseOutlined } from '@ant-design/icons';
import { Button, Card, Form, Input, Select, Typography } from 'antd';
import { useUpdateNodeInternals } from 'reactflow';
import { useBuildCategorizeToOptions, useHandleToSelectChange } from './hooks';
interface IProps {
@ -7,6 +8,7 @@ interface IProps {
}
const DynamicCategorize = ({ nodeId }: IProps) => {
const updateNodeInternals = useUpdateNodeInternals();
const form = Form.useFormInstance();
const options = useBuildCategorizeToOptions();
const { handleSelectChange } = useHandleToSelectChange(
@ -21,6 +23,7 @@ const DynamicCategorize = ({ nodeId }: IProps) => {
const handleAdd = () => {
const idx = fields.length;
add({ name: `Categorize ${idx + 1}` });
if (nodeId) updateNodeInternals(nodeId);
};
return (
<div