Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-42752

JIRA.Events.NEW_CONTENT_ADDED event is triggered twice when reloading/refreshing an issue

    XMLWordPrintable

Details

    Description

      Summary

      When binding JIRA.Events.NEW_CONTENT_ADDED to JIRA issues (eg: via a webpanel), the event will be triggered twice when an issue is refreshed. This is confirmed by adding a console logging to the script:

      Steps to Reproduce

      1. Create a test plugin, containing a web resource containing a javascript which is attached to the issue view:
        <web-resource key="components-mod-resources" name="components-mod Web Resources">
                <dependency>com.atlassian.auiplugin:ajs</dependency>
                <resource type="download" name="test-script.js" location="/js/test-script.js"/>
                <context>jira.view.issue</context>
        </web-resource>
        
        AJS.$(function() {
            JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context, reason) {
                if (AJS.$('#my-test-element').length != 0) {
                    if (reason == JIRA.CONTENT_ADDED_REASON.pageLoad) {
                        console.log("Page Load");
                    } else if (reason == JIRA.CONTENT_ADDED_REASON.panelRefreshed) {
                        console.log("Panel Refreshed");
                    }
                }
            });
        });
        
      2. Once the plugin has been installed on a JIRA instance, access a test issue with the browser console opened.
      3. After the issue is loaded, refresh the issue for the first time by clicking on the issue key on the issue view:
      4. After the issue is refreshed, click on the issue key again and the event will be triggered twice:

      Expected Results

      The JIRA.Events.NEW_CONTENT_ADDED should be triggered once for each time an issue is refreshed.

      Actual Results

      The JIRA.Events.NEW_CONTENT_ADDED will be triggered twice when an issue is refreshed more than once.

      Notes

      This behaviour is also reproducible on the Issue Navigator with 'Detail View' enabled, when selecting between issues on the list.

      Tested on JIRA 6.3.15.

      Attachments

        1. scshot.png
          scshot.png
          146 kB
        2. scshot.png
          scshot.png
          145 kB
        3. scshot2.png
          scshot2.png
          57 kB

        Issue Links

          Activity

            People

              Unassigned Unassigned
              afaisal Ahmad Faisal (Inactive)
              Votes:
              29 Vote for this issue
              Watchers:
              31 Start watching this issue

              Dates

                Created:
                Updated: