Skip to content

Conversation

@graycreate
Copy link
Member

Summary

Implements the proper SwiftUI approach for detecting tab reselection to enable scroll-to-top behavior when tapping an active tab item.

Changes

  • Add Combine PassthroughSubject to capture all tab tap events
  • Create intermediate binding that publishes events for both tab switches and same-tab taps
  • Use onReceive modifier to dispatch TabbarClickAction for all tab interactions
  • Pure SwiftUI solution using Combine instead of UIKit introspection

Behavior

This enables the standard iOS behavior where tapping an already-selected tab scrolls the content to the top, matching the UX of native iOS apps like Safari, Settings, etc.

Technical Details

  • The intermediate binding's setter is called for every tab tap
  • PassthroughSubject publishes the event even when tapping the same tab
  • The existing TabbarClickAction and reducer logic handle the scroll-to-top functionality
  • Only updates the actual selection state when switching to a different tab

Test Plan

  • Build and run on device
  • Navigate to any tab and scroll down
  • Tap the same tab item again
  • Verify content scrolls smoothly to the top
  • Test on all four tabs: Feed, Explore, Message, Me

🤖 Generated with Claude Code

Implement proper SwiftUI approach for detecting tab reselection:
- Add Combine PassthroughSubject to capture all tab taps
- Create intermediate binding that publishes tap events
- Use onReceive to dispatch TabbarClickAction for scroll-to-top
- Works for both tab switches and same-tab taps
- Pure SwiftUI solution without UIKit introspection

This enables the native iOS behavior where tapping an active tab
scrolls content to the top, matching standard iOS app behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings October 17, 2025 12:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Implements proper SwiftUI approach for detecting tab reselection to enable scroll-to-top behavior when tapping an already-selected tab item, using Combine PassthroughSubject and intermediate binding instead of UIKit introspection.

  • Adds Combine framework integration with PassthroughSubject to capture all tab tap events
  • Creates intermediate binding that publishes events for both tab switches and same-tab taps
  • Uses onReceive modifier to dispatch TabbarClickAction for all tab interactions

@github-actions
Copy link

Code Coverage Report ❌

Current coverage: 0%

Apply Copilot suggestion to always update selectedTab binding value,
even when tapping the same tab. This ensures the TabView selection
stays in sync and simplifies the binding logic.

Setting the same value is harmless in SwiftUI and prevents potential
sync issues between the intermediate binding and the actual state.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions bot added size/S and removed size/S labels Oct 17, 2025
@github-actions
Copy link

Code Coverage Report ❌

Current coverage: 0%

@graycreate graycreate merged commit 053bfdd into main Oct 17, 2025
6 checks passed
@graycreate graycreate deleted the feature/native-tabview-scroll-to-top branch October 17, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants