Skip to content

Fix power toggle gesture conflict on iOS 16#81

Merged
Moustachauve merged 4 commits intomainfrom
fix-power-toggle-opens
Apr 5, 2026
Merged

Fix power toggle gesture conflict on iOS 16#81
Moustachauve merged 4 commits intomainfrom
fix-power-toggle-opens

Conversation

@Moustachauve
Copy link
Copy Markdown
Owner

🛠️ Fix: Power Toggle Gesture Conflict on iOS 16

This fixes #73

📝 Summary

This PR fixes a bug on iOS 16 where tapping a device's power toggle in the list would simultaneously open the device detail view.

On iOS 16, SwiftUI's .onTapGesture on a parent (the List row) is too "greedy" and triggers even when a child interactive control like a Toggle is tapped. This resulted in the app toggling the power and navigating to the detail screen at the same time.

💡 The Solution

Added an empty .onTapGesture { } specifically to the child Toggle. SwiftUI's gesture system prioritizes the child's (more specific) gesture recognizer. This empty handler "claims" the tap, preventing it from bubbling up to the parent row. Because the Toggle uses UIKit's UISwitch under the hood, it still correctly receives the touch event via UIKit and functions normally.

✅ Verified

  • Tapping the power toggle on iOS 16 toggles the device without navigating.
  • Tapping the power toggle on later iOS versions (iOS 17+) does not trigger navigation.
  • Tapping elsewhere on the device card still triggers navigation correctly.

@Moustachauve Moustachauve added bug Something isn't working fix patch For fixes. labels Apr 4, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds an empty .onTapGesture handler to the Toggle component in DeviceListItemView to prevent gesture conflicts on iOS 16. The reviewer suggests applying this same workaround to the Slider component to ensure consistent behavior and prevent accidental navigation when adjusting settings.

Comment thread wled/View/DeviceListItemView.swift
- Make backgroundDisconnectDelay injectable so tests use milliseconds
  instead of multi-second wall-clock sleeps
- Pipe xcodebuild through xcbeautify for readable CI logs
- Generate JUnit XML report for test results
@github-actions github-actions Bot added the chore For changes that are mostly maintenance work. label Apr 5, 2026
- Make backgroundDisconnectDelay injectable so tests use milliseconds
  instead of multi-second wall-clock sleeps
- Pipe xcodebuild through xcbeautify for readable CI logs
- Generate JUnit XML report for test results
@Moustachauve Moustachauve merged commit 16eee4c into main Apr 5, 2026
4 checks passed
@Moustachauve Moustachauve deleted the fix-power-toggle-opens branch April 5, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working chore For changes that are mostly maintenance work. fix patch For fixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toggling a light on/off on iOS 16 opens the device webview

1 participant