Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to [dmn-js-properties-panel](https://github.com/bpmn-io/dmn-

___Note:__ Yet to be released changes appear here._

## 3.8.3

* `FIX`: update on `import.done` instead of `root.added` to prevent stale element ([#128](https://github.com/bpmn-io/dmn-js-properties-panel/pull/128))

## 3.8.2

* `FIX`: reverts keeping selected element in sync with canvas state ([#122](https://github.com/bpmn-io/dmn-js-properties-panel/pull/122))
Expand Down
18 changes: 7 additions & 11 deletions src/render/DmnPropertiesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,20 @@ export default function DmnPropertiesPanel(props) {
};
}, [ selectedElement ]);

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

if (isImplicitRoot(element)) {
return;
}
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
31 changes: 8 additions & 23 deletions test/spec/DmnPropertiesPanel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,29 +244,6 @@ describe('<DmnPropertiesPanel>', function() {
});
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test for the old root.added event behavior was removed, but no test was added for the new import.done event behavior. Consider adding a test to verify that the properties panel updates correctly when import.done is fired, similar to the removed test but checking for the import.done event instead.

Copilot uses AI. Check for mistakes.


it('should not update on implicit root added',function() {

// given
const updateSpy = sinon.spy();

const eventBus = new eventBusMock();

eventBus.on('propertiesPanel.updated', updateSpy);

createDmnPropertiesPanel({ container, eventBus });

// when
eventBus.fire('root.added', {
element: {
isImplicit: true
}
});

// expect
expect(updateSpy).to.not.have.been.called;
});


it('should not update on implicit root selected',function() {

// given
Expand Down Expand Up @@ -401,16 +378,24 @@ function createDmnPropertiesPanel(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