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

MathJax filter causes page to scroll to anchor

XMLWordPrintable

    • MOODLE_38_STABLE
    • MOODLE_38_STABLE
    • MDL-67117-master-2
    • 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.

      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.

            marina Marina Glancy
            marina Marina Glancy
            Rafael Lechugo Rafael Lechugo
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.