cancel
Showing results for 
Search instead for 
Did you mean: 

nodeClick event is called several times

qwertz
Confirmed Champ
Confirmed Champ

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 5

dvuika
Star Collaborator
Star Collaborator

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

qwertz
Confirmed Champ
Confirmed Champ

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
Star Collaborator
Star Collaborator

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
Confirmed Champ
Confirmed Champ

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
Star Collaborator
Star Collaborator

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