Pressing 'download' while still editing text ignores changes

In the demo on https://demo.bpmn.io/new, If you’re editing the name of an element and then click either of the download buttons at the bottom, this new name isn’t included in the download.

It seems the text is only saved if you click outside of the textbox, but still on the svg element. I’m dealing with the same behaviour in my application, where users expect the text to be updated when they press my save button.

Is there anything I can do to trigger the text save when the user clicks anywere outside of the modeler? Or could this be fixed in another way?

You can add this behavior by triggering directEditing.complete whenever the user does something that results in exporting the diagram.

What do you mean exactly? When I try to fire the directEditing.comple event as below, nothing appears to change:
bpmnViewer.get('eventBus').fire('directEditing.complete')

However, after I fire that event I can no longer dismiss the edit box, it gives me the folowing error:
TypeError: Cannot read property 'id' of undefined

Which is guess makes sense as the defined event handler seems to clear a few things.

Try this:

var directEditing = modeler.get('directEditing');

if (directEditing && directEditing.isActive()) {
  directEditing.complete();
}

That fixed it, thanks a lot!