Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-67117

MathJax filter causes page to scroll to anchor

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Download the script in the attachment and copy to wwwroot
      2. Open it in your browser, you will see 2 tabs: "Default tab" and "Click here".
      3. Click on the "Click here" tab.
      4. Verify that a new text, in bold, appears in the page, under the tabs. The text is "Please verify that no scroll happened when clicking on the "Click here" tab and this message appeared automatically."
      5. Verify that the page does not scroll at all and you saw the text above appearing in place.
      Show
      Download the script in the attachment and copy to wwwroot Open it in your browser, you will see 2 tabs: "Default tab" and "Click here". Click on the "Click here" tab. Verify that a new text, in bold, appears in the page, under the tabs. The text is " Please verify that no scroll happened when clicking on the "Click here" tab and this message appeared automatically. " Verify that the page does not scroll at all and you saw the text above appearing in place.
    • Affected Branches:
      MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull Master Branch:
      MDL-67117-master-2

      Description

      In Moodle 3.8 new code was added to theme/boost/amd/src/loader.js that replaces the URL with the tab name when switching to the tab.

      Moodle Workplace had similar code since 3.7 but it was causing scrolling so we created a workaround. In 3.8 we are trying to use the core functionality but the page keeps scrolling.

      After several hours of debugging I figured out that it is MathJax filter that causes the page to scroll.

      1. Use attached test files "testtabs.php", place it in wwwroot and open in the browser
      2. Click on the second tab, you will notice scrolling
      3. Go to "Site aministration>Plugins>Manage filters" and disable MathJax filter
      4. Go back to testtabs.php
      5. Now if you click on second tab the page does not scroll
      6. (Enable filter back)

      Why it happens:

      When we click on the second tab we want to dynamically load content, so we use "Templates.replaceNodeContents", which calls "event.notifyFilterContentUpdated(newNodes);"

      MathJax filter listens to this event and tries to substitute the mathjax content. Even if there is no mathjax content in the new nodes, it still calls function "_setLocale()" which calls "window.MathJax.Hub.Configured()"

      The later causes scrolling. Why? No idea. I could not find anything while googling.

      If you remove this line
      https://github.com/moodle/moodle/blob/master/filter/mathjaxloader/yui/src/loader/js/loader.js#L81
      scrolling stops happening.

      I would REALLY appreciate help on this, it's quite critical in upgrading Moodle Workplace to 3.8. Also it will become a problem for any users of bootstrap tabs in 3.8 with dynamically loaded content.

        Attachments

          Activity

            People

            Assignee:
            marina Marina Glancy
            Reporter:
            marina Marina Glancy
            Peer reviewer:
            Rafael Lechugo
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Janelle Barcega
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              18/Nov/19

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 7 hours
                7h