You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alexandre Madeira (@MadeiraAlexandre) Do you think that's fine to add a scrollToTop if a tap in the TabBarItem is performed and the TabPage is the same (as the item)?
I checked but I’m not really into SwiftUI and I can’t find an easy implementation of that feature.
The idea is common to other apps that uses a TabBar: when you are already on the main page (popToRoot alike) and you tap again the current TabBarItem, the UI scroll to the top
Alexandre Madeira (@MadeiraAlexandre) Do you think is fine to add a scrollToTop if a tap in the TabBarItem is performed and the TabPage is the same (as the item).
I checked but I’m not really into SwiftUI and I can’t find an easy implementation of that feature.
Yes, it is fine. I've done it for Kitsune for MyAnimeList (on the Season and Profile page, on the others tabs I'll do it in a future update).
You can control it by using a ScrollViewReader and use a binding to trigger the scroll to the top.
I've done something like this on the computed property: if seasonPath.isEmpty { scrollSeasonToTop.toggle() } else { seasonPath = .init() }
I pass this bool binding to the SeasonView and it can trigger the scrolling to the top, usually using a hidden circle on the top of the view like this one: Circle().fill(.clear).frame(width: 0, height: 0).hidden().id("top_view").onChange(of: scrollToTop) { withAnimation { proxy.scrollTo("top_view", anchor: .top) } }
On tabs with search field, you could even scroll to the top and then trigger the search field (like Apple does on Apple Music app).
On Cronica I've set it to open the search field only on the Search page, but you could adapt it to make it work with scrolling too and even bring the same behavior to Watchlist tab. (The file used is TabBarView.swift).
I'll reopen this issue as a reminder to do it in a future update.
Tab re-tap behavior is handled in TabBarView via per-tab NavigationPath state: re-selecting the active tab clears the stack (homePath, explorePath, watchlistPath, searchPath) and returns to the root screen. On Search, a re-tap while already at root also focuses the search field.
This covers the original “tap tab bar item to return to main page” request. Scroll-to-top while already at root (discussed later in the thread) can be tracked separately if still desired.
Activity
Improved Tab Bar navigation UX
MadeiraAlexandre commentedon May 20, 2024
Set to release on the App Store as version 2.7.3.
kevinm6 commentedon Jun 2, 2024
Alexandre Madeira (@MadeiraAlexandre) Do you think that's fine to add a
scrollToTopif a tap in the TabBarItem is performed and the TabPage is the same (as the item)?I checked but I’m not really into
SwiftUIand I can’t find an easy implementation of that feature.The idea is common to other apps that uses a TabBar: when you are already on the main page (
popToRootalike) and you tap again the current TabBarItem, the UI scroll to the topMadeiraAlexandre commentedon Jun 2, 2024
Yes, it is fine. I've done it for Kitsune for MyAnimeList (on the Season and Profile page, on the others tabs I'll do it in a future update).
You can control it by using a ScrollViewReader and use a binding to trigger the scroll to the top.
I've done something like this on the computed property:
if seasonPath.isEmpty { scrollSeasonToTop.toggle() } else { seasonPath = .init() }I pass this bool binding to the SeasonView and it can trigger the scrolling to the top, usually using a hidden circle on the top of the view like this one:
Circle().fill(.clear).frame(width: 0, height: 0).hidden().id("top_view").onChange(of: scrollToTop) { withAnimation { proxy.scrollTo("top_view", anchor: .top) } }On tabs with search field, you could even scroll to the top and then trigger the search field (like Apple does on Apple Music app).
On Cronica I've set it to open the search field only on the Search page, but you could adapt it to make it work with scrolling too and even bring the same behavior to Watchlist tab. (The file used is TabBarView.swift).
I'll reopen this issue as a reminder to do it in a future update.
kevinm6 commentedon Jun 2, 2024
Thanks Alexandre Madeira (@MadeiraAlexandre) , that's awesome!
Yes, I saw what you've done in the
SearchViewto trigger the search-on-tap with the Boolean var.MadeiraAlexandre commentedon Jul 3, 2024
There's some big changes to how TabView operates on iOS and iPadOS 18. Some of this changes could also reduce code for the macOS side.
Some changes will be likely require on the iPadOS side.
New documentation:
https://developer.apple.com/wwdc24/10147
https://developer.apple.com/documentation/SwiftUI/Enhancing-your-app-content-with-tab-navigation
tomegger commentedon Aug 24, 2026
Closing as implemented.
Tab re-tap behavior is handled in
TabBarViewvia per-tabNavigationPathstate: re-selecting the active tab clears the stack (homePath,explorePath,watchlistPath,searchPath) and returns to the root screen. On Search, a re-tap while already at root also focuses the search field.This covers the original “tap tab bar item to return to main page” request. Scroll-to-top while already at root (discussed later in the thread) can be tracked separately if still desired.