SwiftUI: Strange empty popover near TextField - swiftui

Each time when I write character in TextField - displayed empty popover near the field.
It is displayed only on last MacOS/SwiftUI on few computers, but cannot be reproduced on older OS/SwiftUI.
Reproduced on:
macOS: 12.2 (21D49) + 12.2.1
xCode: 13.2.1 (13C100)
Looks like it does not reproduces on 12.2b
Anyone know how to fix it?
HStack {
VStack(alignment: .trailing, spacing: 12) {
Text("Username or email:")
Text("Password:")
}
VStack {
// REPRODUCED ONLY HERE
TextField ("Username or email", text: $email)
SecureField("Password", text: $password)
}
.frame(width: 190)
}
.padding(.bottom, 15)
Update:
It is can be reproduced on macOS 12.2.1
It opens "empty popup" with size of last opened context menu - if I click on password field it's opens passwords context menu and after this I will see:
UPD:
Bug does not reproduce on macOS Ventura 13.0.1 (22A400)

I could reproduce this issue with macOS 12.3 and Xcode 13.3. Explicitly setting the NSTextContentType of the SecureField (via .textContentType(.password)) fixed it for me.

Related

How do we clear the icon in SwiftUI Pickers when switching from Label content to Text?

I'm curious, is a mix of Label and Text Views supported as the contents of a Picker? I'm seeing some visual glitches around the icon that suggests it is not.
In the example below, the picker initially appears correctly.
Selecting "First Item" works as expected.
But reverting to the original state, by selecting "None", results in a label that still retains a phantom icon from the previous selection.
Can anyone suggest a good workaround, if this is a bug? I tried using a label with an empty string for the systemImage (Label("None", systemImage: "").tag(0)). I also tried using a Label instead of the text, but without icon (Label("None", systemImage: "house").labelStyle(.titleOnly).tag(0)). In both cases the phantom icon was still there.
Here is the full code to illustrate the problem:
struct LabelAndTextInPicker: View {
#State private var selection = 0
var body: some View {
Form {
Picker("Choice", selection: $selection) {
Text("None").tag(0)
Label("First Item", systemImage: "1.circle").tag(1)
Label("Second Item", systemImage: "2.circle").tag(2)
}
.pickerStyle(.menu)
}
}
}
It does look like a bug. As a workaround try this, works for me:
Label {
Text("None")
} icon: {
Image(uiImage: UIImage())
}.tag(0)

Toolbar Menu button seems to look disabled

Overview
On macOS, in a NavigationSplitView when the menu button is added to the detail view toolbar, it seems to look disabled (refer to steps to reproduce)
Question:
Is there a way to not look disabled (2nd time the sidebar cell is tapped)?
Environment
Xcode: 14.1 beta 3 (14B5033e)
macOS: 13.0 Beta (22A5365d)
Code:
struct ContentView: View {
#State private var selectedNumber: Int?
var body: some View {
NavigationSplitView {
List(0..<100, selection: $selectedNumber) { number in
Text("cell \(number)")
}
} detail: {
Text("Detail")
.toolbar {
ToolbarItem {
Menu {
Button("aa") {}
Button("bb") {}
} label: {
Label("Add Bookmark", systemImage: "book")
}
}
}
}
}
}
Steps to reproduce:
Run the project on macOS
Select cell 0 on the sidebar
Click on the book toolbar button and notice the menu appear
Select cell 1 on the sidebar
Expected Behaviour
After step 4, the book toolbar button should look prominent (like it is enabled)
Actual Behaviour
After step 4, the book toolbar button looks like it is disabled.
Screenshot
Feedback
I have filed a feedback, hope it gets fixed.
It might help if more feedbacks are filed as it might help get noticed

Swiftui navigationBarTitle beging overwritten with Preview View Text

When I go to my second page which has a ScrollView, and I scroll to the point it becomes inline and then return to the mainView - the navigationBarTitles is being overwritten with both navigationBarTitles.
I am using Xcode Version 12.5 (12E262) and this is iOS 14.
It is happening both in the simulator and on a device.
MainView
ScrollView
ScrollView scrolled so it becomes inline
And when I return to the MainView from the inline NavBar I get this.
It is fine - unless I have scrolled. And what makes it even more confusing it only does it about 25% of the time.
I am just using "self.presentationMode.wrappedValue.dismiss()" to return to the mainView
I am using a NavigationLink to go to the second page.
NavigationLink(destination: ScrollView(), isActive: $showScroll ) { EmptyView() }
Is there something I have missed when dismissing from Scrolling?
very plain code for the scrollView.
I am obviously missing something or this is a big issue with SwiftUI and Xcode.
Thank you.
var body: some View {
ScrollView(showsIndicators: false) {
}
.navigationBarBackButtonHidden(true)
.navigationBarTitle("scrollView Page")
.navigationBarItems(
leading:
Button(action:{
self.presentationMode.wrappedValue.dismiss()},
label: {
Image(systemName: "arrow.left")
})
}

SwiftUI PageView iOS 13 - Navigation link not working as expected

My project is target for iOS 13 onwards hence could not use PageTabViewStyle(). I tried with Mr. John suggestion from this link
SwiftUI create image slider with dots as indicators
Now I need to open the detail view on clicking the image in the slideshow. But now when I try to move the images the detail view is opening and could not move the images as in Pageview. I implemented the below code. Please let me know the solution to fix this. Thanks in advance.
PagingView(index: $index.animation(), maxIndex: images.count - 1){
ForEach(articles, id: \.self) { article in
NavigationLink(destination: ArticleDetailUIView(article: articles[self.index], isBookmark: false) , isActive: $areYouGoingToArticleView)
{
Image(article.image)
.resizable()
.scaledToFill()
.accessibility(identifier: "articleImage")
}
}
}
.aspectRatio(4/3, contentMode: .fit)
.clipShape(RoundedRectangle(cornerRadius: 15))
After few browsing, the workaround was using the stepper to move around the slide show instead of scrolling the images. I added the below lines.
Stepper("Index: (index)", value: $index.animation(.easeInOut), in: 0...images.count-1)
.font(Font.body.monospacedDigit())
.labelsHidden()

Odd behavior when using multiple SecureFields following a TextField in a SwiftUI view

Note: This bug has been fixed in Xcode 13.0 beta 3
I am experiencing very odd behavior when trying to use multiple SecureFields when following a TextField in a view. Attempting to enter text in one of the SecureFields stops at one character with the field turning yellow and displaying "Strong Password", as well as duplicating in the second SecureField. This is occurring on iOS 14.2 in Xcode 12.2 on the Xcode preview and in the simulator.
Here is a minimal example that demonstrates the issue:
struct SecureFieldTestView: View {
#State var displayName: String = ""
#State var password = ""
#State var passwordVerifiation = ""
var body: some View {
VStack {
TextField("Display name", text: $displayName)
SecureField("Password", text: $password)
SecureField("Verify Password", text: $passwordVerifiation)
}
.padding()
}
}
struct SecureFieldTestView_Previews: PreviewProvider {
static var previews: some View {
SecureFieldTestView()
}
}
The console shows the following errors when running into the simulator:
[AutoFill] Cannot show Automatic Strong Passwords for app bundleID: <REDACTED BY ME> due to error: iCloud Keychain is disabled
[Assert] View <(null):0x0> does not conform to UITextInput protocol
I have tried to wrap the SecureFields into their own VStack{} and wrapping them all into a Form{}, but the issue remains.
Is there something obvious that I am missing or is this a bug in the SDK?
I would report a bug to Apple regarding this issue...
However, for the moment here is a workaround to fix this and still use the SecureField without the yellow bar on top..
SecureField("First", text: $password)
.textContentType(.newPassword)
Just add textContentType for newPassword and that bar won't appear.
On further investigation, there is another issue that was occurring; the software keyboard would not appear until after some delay. Entering text in the SecureFields before the software keyboard appeared consistantly produced the issue. Waiting for the software keyboard to appear resolves the odd behavior.
Strangely, the delay in the keyboard appearance seems to occur when the device/simulator is not logged into iCloud; the keyboard appearance delay and SecureField issue does not occur when the device is logged in.