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

Expand macros in multiple future macros only expand properly for last future macro invoked

      NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.

      When a page contains multiple instances of the future macro which contain expand macros, only the expand macros in the last future macro invoked expand properly. Expand macros on the other (not-invoked-last) future briefly expand then immediately de-expand.

      Why Confluence Expand macro fails:
      Confluence expand macro binds expand-control elements with "click" and "keyup" events when expand-control found on a page. In case of future macro, since it loads asynchronously, binding occurs multiple times for the expand control which loads first.

      Proposed Fix:
      Confluence expand macro shall unbound all events before binding to events, so that events already bound to elements will be cleared. And then bind events to elements afresh.

      $elements.length && $elements.unbind(eventNames); // FIX: unbound events before binding
      $elements.length && $elements.bind(eventNames, helper.createToggleFunction(eventMatcher));
      

      With this fix put in place for confluence expand macro, it works well with multiple expands with or without future macro.

            [CONFSERVER-40562] Expand macros in multiple future macros only expand properly for last future macro invoked

            John Tian added a comment - - edited

            I'm encountering a similar problem, but all Expand macros are immediately auto-collapsing. Doesn't matter if I put Expand inside Future, or Future inside Expand.
            I made a page that consists only of:

            • Future
              • Expand
                • Some plaintext
            • Expand
              • Future
                • Some plaintext

            And it still exhibits this issue.

            Currently on Confluence 7.12.0

            EDIT: found a workaround? Setting the Future macro to use manual rendering, and placing Expand inside Future, appears to avoid this issue.

            John Tian added a comment - - edited I'm encountering a similar problem, but all Expand macros are immediately auto-collapsing. Doesn't matter if I put Expand inside Future, or Future inside Expand. I made a page that consists only of: Future Expand Some plaintext Expand Future Some plaintext And it still exhibits this issue. Currently on Confluence 7.12.0 EDIT: found a workaround? Setting the Future macro to use manual rendering, and placing Expand inside Future, appears to avoid this issue.

            Hi Atlassian,

            Can you please expedite this fix? Thank you.

            Nishanth Thimmareddy (Appfire) added a comment - Hi Atlassian, Can you please expedite this fix? Thank you.

            Hello Dear Atlassian!
            Would you mind me asking if there are any updates?
            We are extremely in need of fixing this bug.

            Pavel Luksha added a comment - Hello Dear Atlassian! Would you mind me asking if there are any updates? We are extremely in need of fixing this bug.

            This is there from Confluence 5.3 onwards. I have not checked with version prior to 5.3.

            Sunita Patro {Appfire} added a comment - This is there from Confluence 5.3 onwards. I have not checked with version prior to 5.3.

            Minh Tran added a comment -

            Dear spatro,

            Thanks for submitting the ticket
            Would you please let me know what affect version of Confluence that you met this issue?

            Thanks,
            Minh Tran
            Confluence BugMaster
            Atlassian

            Minh Tran added a comment - Dear spatro , Thanks for submitting the ticket Would you please let me know what affect version of Confluence that you met this issue? Thanks, Minh Tran Confluence BugMaster Atlassian

            Detail analysis for reference

            Confluence expand macro binds expand-control elements with "click" and "keyup" events when expand-control found on a page. In case of future macro, since it loads asynchronously, binding occurs multiple times for the expand control which loads first.

            Example: There are 2 future embedding expand macros (say future-expand1, future-expand2) on a page.

            1. When 1st future loads, there is 1 expand control found on page, that is future-expand1 and it is bound to "click" and "keyup" events.

            2. When 2nd future loads, there are 2 expand controls found on page, they are future-expand1 and future-expand2.

            • future-expand1 again bound to "click" and "keyup" events.
            • future-expand2 bound to "click" and "keyup" events.

            3. At the end :

            • future-expand1 bound to "click" and "keyup" events TWICE.
            • future-expand2 bound to "click" and "keyup" events once.

            Since future-expand1 is bound twice with the events, on click or key up, the binding function called twice and every time a binding function called, it toggles the expand/collapse feature of the expand control.

            Hence the one that got loaded first expands and collapses instead of just expand or collapse. Where as the last one loaded behaves well (on click either expand or collapse but not both) since its bound to events only once.

            Sunita Patro {Appfire} added a comment - Detail analysis for reference Confluence expand macro binds expand-control elements with "click" and "keyup" events when expand-control found on a page. In case of future macro, since it loads asynchronously, binding occurs multiple times for the expand control which loads first. Example: There are 2 future embedding expand macros (say future-expand1, future-expand2) on a page. 1. When 1st future loads, there is 1 expand control found on page, that is future-expand1 and it is bound to "click" and "keyup" events. 2. When 2nd future loads, there are 2 expand controls found on page, they are future-expand1 and future-expand2. future-expand1 again bound to "click" and "keyup" events. future-expand2 bound to "click" and "keyup" events. 3. At the end : future-expand1 bound to "click" and "keyup" events TWICE. future-expand2 bound to "click" and "keyup" events once. Since future-expand1 is bound twice with the events, on click or key up, the binding function called twice and every time a binding function called, it toggles the expand/collapse feature of the expand control. Hence the one that got loaded first expands and collapses instead of just expand or collapse. Where as the last one loaded behaves well (on click either expand or collapse but not both) since its bound to events only once.

              Unassigned Unassigned
              b6c1d371603e Sunita Patro {Appfire}
              Affected customers:
              13 This affects my team
              Watchers:
              12 Start watching this issue

                Created:
                Updated: