Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/render/BpmnPropertiesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,20 @@ export default function BpmnPropertiesPanel(props) {
};
}, [ selectedElement ]);

// (2c) root element changed
// (2c) import done
useEffect(() => {
const onRootAdded = (e) => {
const element = e.element;
const onImportDone = () => {
const rootElement = canvas.getRootElement();

_update(element);
_update(rootElement);
};

eventBus.on('root.added', onRootAdded);
eventBus.on('import.done', onImportDone);

return () => {
eventBus.off('root.added', onRootAdded);
eventBus.off('import.done', onImportDone);
};
}, [ selectedElement ]);
}, []);

// (2d) provided entries changed
useEffect(() => {
Expand Down
12 changes: 10 additions & 2 deletions test/spec/BpmnPropertiesPanel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('<BpmnPropertiesPanel>', function() {
});


it('should update on root element changed', function() {
it('should update on import done', function() {

// given
const updateSpy = sinon.spy();
Expand All @@ -237,7 +237,7 @@ describe('<BpmnPropertiesPanel>', function() {
createBpmnPropertiesPanel({ container, eventBus });

// when
eventBus.fire('root.added', { element: noopElement });
eventBus.fire('import.done');

// then
expect(updateSpy).to.have.been.calledWith({
Expand Down Expand Up @@ -450,16 +450,24 @@ function createBpmnPropertiesPanel(options = {}) {
} = options;

let {
canvas,
elementRegistry
} = options;

if (!canvas) {
canvas = {
getRootElement: () => noopElement
};
}

if (!elementRegistry) {
elementRegistry = new elementRegistryMock();
elementRegistry.setElements([ element ]);
}

const injector = new injectorMock({
...options,
canvas,
elementRegistry
});

Expand Down
2 changes: 1 addition & 1 deletion test/spec/mocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Injector {
}

if (type === 'canvas') {
return new Canvas();
return this._options.canvas || new Canvas();
}
}
}
Expand Down
Loading