Only run ensureActivatedTab()
after renderMenu()
for sidebarMenus
#233
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes [#229]: only run
ensureActivatedTab()
afterrenderMenu()
is called if theel
in question has class"sidebar-menu"
. Since this function is used for bothdropdownMenuOutput
andsidebarMenuOutput
, 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 ifel
has 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