 
     @objc func tappedButton(_ sender: UIButton!) {
         for (index, button) in buttons.enumerated() where button == sender {
-            selectedPanel = LibraryPanelType(rawValue: index)
+            let newSelectedPanel = LibraryPanelType(rawValue: index)
+
+            // If we're already on the selected panel and the user has
+            // tapped for a second time, pop it to the root view controller.
+            if newSelectedPanel == selectedPanel {
+                let panel = self.panelDescriptors[safe: index]?.navigationController
+                panel?.popToRootViewController(animated: true)
+            }
+
+            selectedPanel = newSelectedPanel
             if selectedPanel == .bookmarks {
                 UnifiedTelemetry.recordEvent(category: .action, method: .view, object: .bookmarksPanel, value: .homePanelTabButton)
             } else if selectedPanel == .downloads {

                if index < buttons.count {
                    let currentButton = buttons[index]
                    currentButton.isSelected = false
                    currentButton.isUserInteractionEnabled = true
                }
            }


                if index < buttons.count {
                    let newButton = buttons[index]
                    newButton.isSelected = true
                }

                if index < panelDescriptors.count {
