focusField method

bool focusField(
  1. String? fieldName
)

Implementation

bool focusField(String? fieldName) {
  if (fieldName == null) return false;

  var component = getFieldComponent(fieldName);

  if (component.asJSAny.isA<HTMLElement>()) {
    (component as HTMLElement).focus();
    return true;
  } else if (component is UIComponent) {
    var input = findInContentChildDeep((e) => e.isTextInput);
    if (input != null) {
      return input.focus();
    }

    var content = component.content;
    if (content != null) {
      content.focus();
      return true;
    } else {
      return false;
    }
  }

  return false;
}