Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upOnly run `ensureActivatedTab()` after `renderMenu()` for sidebarMenus #233
Conversation
… `el` in question has class "sidebar-menu". (fixes #229)
Fixes [#229]: only run
ensureActivatedTab()afterrenderMenu()is called if theelin question has class"sidebar-menu". Since this function is used for bothdropdownMenuOutputandsidebarMenuOutput, we have to make sure thatensureActivatedTab()is only called if it's the latter case (otherwise, you get unexpected tab redirections when updating a dropdown menu).We only started calling
ensureActivatedTab()after arenderMenu()call in commit 18b3505. This fixed a long-time bug that unselected/deactivated all tabs when you dynamically created a sidebar menu. This example illustrates the problem (i.e. before this fix, nothing would be selected):app.R
However, this introduced a new bug for all other menus that use the
renderMenu()function, in addition to thesidebarMenu(). As issues #229 and #232 show, this code results in weird tab redirections when you userenderValue()to render another type of menu (in those issues, that was adropdownMenu()).This PR fixes this second issue (while making sure that the first issue does not resurface). It does so quite simply: inside
renderValue(), check ifelhas the class "sidebar-menu" and only then, callensureActivatedTab().It also adds another manual test to be repro this issue in the future. Before this fix, you would observe that when the selected tab is not the first, and the
renderMenu()is invalidated, the first tab gets selected. This was particularly annoying in the app below:app.R