I'm trying to make my textField (NSViewRepresentable wrapped NSTextField) the first responder when it appears. I have tested many answers in this thread, but they are either not working: 
func updateNSView(_ nsView: MyField, context: Context) {
  if some_condition {
    print(nsViews.becomeFirstResponder()) // returns false
    negate_condition()
  }
  ...
}
Or it crashes with logs (=== AttributeGraph: cycle detected through attribute 43 ===):
func updateNSView(_ nsViews: MyField, context: Context) {
  if some_condition {
    Window.thisWindow?.makeFirstResponder(nsViews)
    negate_condition()
  }
  ...
}
What I am trying to achieve is:
@State var fieldActive: Bool
body: some View {
  MyField(...).onAppear { /*makeFirstResponder if fieldActive == true*/ }
}
Can someone please help me on this? Thank you very much!
 
     
    