Skip to content

Commit 1bea1fb

Browse files
graycreateclaude
andcommitted
fix: update tab selection unconditionally for consistency
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>
1 parent ee0f1d0 commit 1bea1fb

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

V2er/View/MainPage.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,12 @@ struct MainPage: StateView {
3030
Binding(
3131
get: { selectedTab.wrappedValue },
3232
set: { newValue in
33-
let currentTab = selectedTab.wrappedValue
34-
3533
// Publish the tap event before changing the value
3634
// This allows us to detect same-tab taps
3735
tabReselectionPublisher.send(newValue)
3836

39-
// Update the actual selection
40-
if newValue != currentTab {
41-
selectedTab.wrappedValue = newValue
42-
}
37+
// Always update the selection to maintain consistency
38+
selectedTab.wrappedValue = newValue
4339
}
4440
)
4541
}

0 commit comments

Comments
 (0)