Just to confirm your observations -- interesting bug...
It also happens if you use App-Switcher to switch to another app -- no need to put the device to sleep. Also occurs using the Simulator.
Best way to see what's going on is - with your demonstration project:
launch the app
in Xcode, select View Debug Hierarchy
you'll see lots of rectangles (showing the various SwiftUI generated objects/layers), all aligned with the rendered button
continue execution
tap the button to present the green sheet
swipe up from the bottom or use App-Switcher to send this app to the background
switch back to this app and drag down to dismiss the green sheet
go back to Xcode and select View Debug Hierarchy again
you'll now see the misaligned rectangles
Note: if we then do something to force a layout update - such as rotate the device - the issue corrects itself.
You should file a bug report.
Post
Replies
Boosts
Views
Activity
Couple options, but one approach is to implement touchesBegan instead of adding a tap gesture:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if insertFld.isFirstResponder
{
insertFld.resignFirstResponder()
insertFld.text = ""
insertButton.isEnabled = false
// print("They emptied the fld when editing", gItemID)
gItemID = 0
insertButton.filled_Red_Back(title: K.Titles.add_Btn)
theOriginal_Text = ""
}
}
Any UI element that responds to touch (the field, button, collection view, etc) will consume the touch, so touchesBegan will only be triggered when touching the view itself (or some other non-interactive element).