Hi @Emperor3,
Sorry to hear you are still having troubles. I have a few thoughts on both issues.
The Lingering Link
If I understand the issue correctly, the link "Hypothesis Testing` appears on other tabs? This is puzzling, but I have a few ideas on how to debug this problem.
-
What happens when you comment out the text block "more about sample size ad power calculations can be found..." on the tab "Statistics"? Does the text still appear in unwanted places?
-
What happens when you comment out all text on the "others" tab? Does the stubborn link appear in the "hypothesis testing" tab?
-
What happens when you comment out the entire tab "Statistics"? Is the text still there?
-
What happens when you comment out the entire tab "Others"? Is the text still there?
-
Are there any warnings in the js console? (i.e., Inspect Element)?
Perhaps there is some extra text? Another idea may be that a block of text is placed outside a tabPanel and the code is still structured properly that no errors were detected (the option I'm placing my money on). Without seeing the actual code, it's hard to say for sure. I hope this may point you in the right direction.
Internal Links
I may be able to offer a solution for this part. Every time a shiny app is launched, values for the href attribute in the <a> element(s) are regenerated. This makes traditional hyperlink calls <a href="#mytab">mytab</a> impossible. One way is to work with the attribute data-value which can be accessed via the argument value in tabPanel function.
By default, the value for argument title is automatically assigned to the argument value (see R reference page below). However, it might be useful to manually set the value to a shorter string. Using the screenshots above, for the tab "Paired t-test" you may want to write the value as "tab-t-test".
Next, add the following js function to the UI header. This function loops through all the values in the data-value to look for the desired tab (I adapted code from this SO post -- I'll update when I've found the link). When a match is found, to simulate a mouse click using link.click (this will advance the screen to the desired tab).
var customHref = function(tabName) {
var dropdownList = document.getElementsByTagName( class="value">"a");
for (var i = 0; i < dropdownList.length; i++) {
var link = dropdownList[i];
if(link.getAttribute("data-value") == tabName) {
link.click();
}
}
};
You can either place this at the top of the UI or store in a separate file and load using includeScript or tags$script. For manually creating links, use the tag a() and instead of using href we will set an onclick event.
tabPanel(
"Some content here.",
"More content",
a("onclick"="customHref('mytab')","mytab"),
"More content"
)
To summarize you will need three things.
- The javascript function
- manually assign values to each tab
- manually set the target tab by assigning an onclick event
I've written up this method and posted a few example apps that may help you build the app using this approach. You can find them here. One known issue is that on smaller devices, the navigation bar will stay open after a link is clicked. I have a work around for single-page apps, but I've yet to figure out how to apply it to apps with many pages/tabs.
Hope that helps!
https://shiny.rstudio.com/reference/shiny/1.0.2/tabPanel.html
EDIT: I missed a couple of end quotes