When using AUI Tabs, clicking on the tab causes the page to scoll.

Nicolas Castel had asked this question, but I couldn't comment with my answer so I'm starting a new post.

I've had this problem with the Keysight HTML Elements.  I think I finally found the answer so I'll share.

The AUI Tabs relies on some simple html - an unordered list of anchors for the menu items and a matching set of div tags. See https://docs.atlassian.com/aui/8.5.1/docs/tabs.html  for details. When the tab is clicked, two things happen.  First, some javascript changes the visibility of the tabs so that only the one selected is shown.  This is desired behavior.  Next, the browser scrolls down to the anchor.  It's this second behavior which is annoying and needs to be stopped.

My solution is to add a custom class, keysight-tab-menu-item-anchor, to the anchor tags so they are easy to extract with jQuery, then insert the following javascript:


// Without this hook, Confluence will scroll the page
// so that the top of the tab is at the top of the screen.
// This code triggers the tab change, than stops propagation
// or the event so the page is not scrolled.
AJS.tabs.change(jQuery(this), e)

 This code seems to work just fine. :)

1 comment

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
November 30, 2021

This is still useful. Thank you.


Log in or Sign up to comment
AUG Leaders

Atlassian Community Events