Browse Source

fix: trigger updating dependency UI in basic panel after changing code

master
smallstonesk 4 years ago
parent
commit
bfd4218caf
  1. 2
      packages/core/src/mods/flowChart/codeEditorModel/index.tsx
  2. 9
      packages/core/src/mods/settingBar/mods/basic/index.tsx

2
packages/core/src/mods/flowChart/codeEditorModel/index.tsx

@ -52,6 +52,8 @@ const CodeEditModal: React.FC<IProps> = (props) => {
code,
dependencies: JSON.stringify(newDeps, null, 2)
});
// NOTE: notify basic panel to update dependency
flowChart.trigger('settingBar.basicPanel:forceUpdate');
},
});
}

9
packages/core/src/mods/settingBar/mods/basic/index.tsx

@ -23,7 +23,7 @@ interface IBasicData {
}
const Basic: React.FC<IProps> = (props) => {
const { selectedCell } = props;
const { selectedCell, flowChart } = props;
const [data, setData] = useState<IBasicData>(selectedCell.getData());
const { label, trigger, dependencies, configSchema } = data || {};
@ -31,6 +31,13 @@ const Basic: React.FC<IProps> = (props) => {
useEffect(() => {
setData(selectedCell.getData());
}, [selectedCell]);
useEffect(() => {
const handler = () => setData(selectedCell.getData());
flowChart.on('settingBar.basicPanel:forceUpdate', handler);
return () => {
flowChart.off('settingBar.basicPanel:forceUpdate', handler);
};
}, [selectedCell]);
// events
const batchUpdate = (newData: { [key: string]: any }): void => {

Loading…
Cancel
Save