This is the code I came up with that hides the color picker on all elements except bpmn:Task. But it causes a micro-flicker. Is there a better way? If you remove the setTimeout below then it does not work.
export default function SelectiveColorPicker(modeler) {
const eventBus = modeler.get('eventBus');
// Intercept the display of the context pad
eventBus.on('contextPad.create', function (event) {
if (event.target.type !== 'bpmn:Task') {
setTimeout(() => {
const colorPickerEntry = event.pad.html.querySelector('[data-action="set-color"]');
if (colorPickerEntry) {
colorPickerEntry.style.display = 'none';
}
});
}
});
}
The setTimeout function is typically used to introduce a delay before executing a piece of code. In this case, you are using it to delay the hiding of the color picker entry. However, relying on timeouts can sometimes lead to undesired side effects, such as micro-flickering.