elsa-workflows / elsa-designer

A standards-based Workflow Designer built with StencilJS
MIT License
263 stars 89 forks source link

lastClickedLocation not set correctly #22

Closed martin-indexeb closed 4 years ago

martin-indexeb commented 4 years ago

Hi,

Can I suggest a change to the Designer onAddActivityClick event? I found that el.offsetLeft and el.offsetTop were being calculated relative to the parent element, which was already offset in the page (which led to the new elements disappearing as they were rendered off to the right). I amended the call to use getBoundingClientRect which is working okay on my dev install...

  private onAddActivityClick = (e: MouseEvent) => {
    const el = this.elem() as HTMLElement;
    const clientRect = el.getBoundingClientRect();
    this.lastClickedLocation = {
      left: e.pageX - clientRect.left,
      top: e.pageY - clientRect.top
    };
    this.addActivityEvent.emit();
  };
martin-indexeb commented 4 years ago

Just seen you have taken a different approach on the feature/2.0 branch. Feel free to ignore me ;-)