Can't trigger find event

Hi,

I’m trying to trigger the find event externally, but I cant make it work properly. I looked at BpmnKeyboardBindings.js and found this:

  // search labels
  // CTRL + F
  addListener('find', function(context) {

    var event = context.keyEvent;

    if (keyboard.isKey(['f', 'F'], event) && keyboard.isCmd(event)) {
      editorActions.trigger('find');

      return true;
    }
  });

I had the idea of using the editorActions in the same way, so i did this function:

  ativarPesquisa(): void {
    const editorActions = this._modelador.get('editorActions');
    editorActions.trigger('find');
  }

It works great with other actions, but it cant trigger ‘find’ specifically, and i dont know what else to try.

I’m using angular 11 and bpmn-js@8.8.2 .

Thanks in advance!

Hi @Vitor_Sulzbach, welcome :wave:

Firing the editor action works for me, cf. this Code Sandbox.

Please note that the search pad module has to be present.

const searchPad = modeler.get("searchPad");
console.log("Search pad module:", searchPad);

const editorActions = modeler.get("editorActions");
editorActions.trigger("find");

Thanks for the help,

I found the problem. My code didn’t worked because i was triggering the search event inside a click event, so the first was being canceled before even showing up. Your code worked because you did trigger de search on the component init, so it wasn’t being cut by a click event. It took a time but I got the problem haha, Thanks a lot.

1 Like