nodeClick event is called several times

cancel
Showing results for 
Search instead for 
Did you mean: 
qwertz
Active Member II

nodeClick event is called several times

Hello,

I have defined a click handler that is called when a user single-clicks on a node in the document list. I thought that this function is called only once but the more often I click on a folder node, the more often the handler is called. On the first click it is called twice, on the second it's called 6 times, on the third 10 times, etc.. (These numbers are not consistent and different every time I refresh the page but it always starts with 2 calls)

Here is the HTML:

<alfresco-document-list
      #documentList
      [creationMenuActions]="false"
      [currentFolderId]="currentFolderId"
      (error)="onNavigationError($event)"
      (success)="resetError()"
      (preview)="showFile($event)"
      (nodeClick)="onNodeClicked($event)"
      (permissionError)="handlePermissionError($event)"
      [navigationMode]="'click'">

</alfresco-document-list>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

and this is my click handler:

    onNodeClicked(event: any): void {
        this.stopPropagation(event);
        console.log('node clicked');
    }

    private stopPropagation(event: any): void {
        event = event || window.event;
        if (typeof event.stopPropagation !== 'undefined') {
            event.stopPropagation();
        } else {
            event.cancelBubble = true;
        }
    }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The problem exists with or without calling the stopPropagation() function and is present on IE, Firefox and Chrome.

Do you have an idea how I can get onNodeClicked() called only once when a user clicks on a row of the document list?

5 Replies
dvuika
Alfresco Employee

Re: nodeClick event is called several times

The double-click issue with DataTable and DocumentList components has been fixed with ADF 1.6.1

qwertz
Active Member II

Re: nodeClick event is called several times

Thanks for your reply. I am using ADF 1.6.1, at least that's what package.json says:

"ng2-activiti-analytics": "1.6.1",
"ng2-activiti-diagrams": "1.6.1",
"ng2-activiti-form": "1.6.1",
"ng2-activiti-processlist": "1.6.1",
"ng2-activiti-tasklist": "1.6.1",
"ng2-alfresco-core": "1.6.1",
"ng2-alfresco-datatable": "1.6.1",
"ng2-alfresco-documentlist": "1.6.1",
"ng2-alfresco-login": "1.6.1",
"ng2-alfresco-search": "1.6.1",
"ng2-alfresco-social": "1.6.1",
"ng2-alfresco-tag": "1.6.1",
"ng2-alfresco-upload": "1.6.1",
"ng2-alfresco-userinfo": "1.6.1",
"ng2-alfresco-viewer": "1.6.1",
"ng2-alfresco-webscript": "1.6.1",
"ng2-charts": "1.6.0",‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

And my node version is 6.11.1

dvuika
Alfresco Employee

Re: nodeClick event is called several times

Ok, thanks for the clarification. Could you please try the same with the native DOM events the Document List supports? This is mainly just using "(node-click)"  in your case.

qwertz
Active Member II

Re: nodeClick event is called several times

The result is the same with this HTML:

<div (node-click)="onNodeClicked($event)">
    <div>
        <alfresco-document-list
            #documentList
            [creationMenuActions]="false"
            [currentFolderId]="currentFolderId"
            (error)="onNavigationError($event)"
            (success)="resetError()"
            (preview)="showFile($event)"
            (permissionError)="handlePermissionError($event)"
            [navigationMode]="'click'">

        </alfresco-document-list>
    </div>
</div>

Maybe I get this behaviour because I am using the ADF example application from ADF 101 - Getting Started with Alfresco Application Development Framework. This is how I installed it:

npm install -g yo
npm install -g generator-ng2-alfresco-app
yo ng2-alfresco-app

Is it possible that I have an older version of ADF installed despite the version numbers in package.json? 

dvuika
Alfresco Employee

Re: nodeClick event is called several times

It might have an even subscription leak. We will check and raise a bug ticket if needed. Thanks for reporting the issue.