Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-36710

"Edit in Office" button opens attachments twice after using the file browser preview

      In Confluence 5.7, the "Edit in Office" button in the Attachments macro should cause a file to open once.

      However, after accessing any part of the file browser (such as by clicking on any preview on the page), the Edit in Office button now launches the attachment twice.

      This is shown in the attached screencap. In the first pass, the page has just been loaded and the Excel file is launched normally.

      In the second half of the video, after viewing a preview, clicking the Edit in Office button launches the file...but two copies appear, which can be really confusing for the user.

      The problem seems to stem from the fact that the Office Connector is binding the "onclick" event for "Edit in Office" twice: once in com.atlassian.confluence.extra.officeconnector:editinoffice, and a second time in com.atlassian.confluence.extra.officeconnector:file-viewer-plugin.

      The latter binding appears to have been designed to target the edit-in-office link in the "..." dropdown menu within the file browser itself, but the jQuery selector for "office-editable" class is DOM-wide and not scoped to the file browser, so it ends up attaching the onclick handler to all elements on the page, including those in the Attachments macro that already have their own onclick handler already set up:

      /* module-key = 'com.atlassian.confluence.extra.officeconnector:file-viewer-plugin', location = 'templates/extra/editinword/editInOffice.js' */
      AJS.toInit(function ($) {
          var contextPath = AJS.Data.get('context-path');
      
          var editInOfficeLinks = $('#edit-in-word, #edit-in-word-pathauth, a.office-editable, a.office-editable-pathauth');
          editInOfficeLinks.click(function (e) {
              [...]
      

      Note that this bug also causes problems with third-party plugins that have a <dependency> on the Office Connector's file-viewer-plugin component, since the dependency can also cause this behavior to appear every time the page is loaded, without even needing to access the file previewer.

      Workaround

      The following workaround should resolve the problem until the issue is able to be formally fixed in an upcoming version of the product.

      1. Navigate to Confluence Admin > Manage Add-Ons > System (in the dropdown)
      2. Locate the Office Connector plugin and expand it
      3. Expand the modules, locate the module labeled "file-viewer-plugin" and disable it.
      4. Try the Edit in Office functionality again and let us know how it goes

          Form Name

            [CONFSERVER-36710] "Edit in Office" button opens attachments twice after using the file browser preview

              rsu raymo
              7c60ab039b09 Scott Dudley [Inactive]
              Affected customers:
              7 This affects my team
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: