How disable propertie name of task?

I need to disable the name field of the tasks, when I drag the component from the palette to the diagram, it opens in editing mode to enter the value of the name field, I don’t want this behavior, with double click I managed to solve it, it is possible to do the same by drag and drop into the diagram? Which event should I use?

 var priority = 10000;
    eventBus.on('element.dblclick', priority, function (event) {
      const { element } = event;
      if (isAny(element, ['bpmn:Task'])) {
        return false;
      }
    });
    eventBus.on('element.changed', priority, function (event) {
      const { element } = event;
      if (isAny(element, ['bpmn:Task'])) {
        return false; 
      }
    })

Thanks.

Why would you want to disable name editing on bpmn?

Generally speaking, the best way to disable a feature in bpmn-js is to override it using dependency injection. Label editing is defined here:

So you module could do

export const DisableLabelEditingProvider = {
  labelEditingProvider: ["value", null],
  labelEditingPreview: ["value", null],
};

https://codesandbox.io/p/sandbox/modest-tu-qrhgmm?file=%2Fsrc%2FCustomLabelEditing.js%3A1%2C1-5%2C1

1 Like

Perfect, that’s what I needed, thank you very much.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.