Ngx-formly: Set focus of first textbox of form on load

Created on 14 Jul 2018  路  3Comments  路  Source: ngx-formly/ngx-formly

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[x ] support request

Current behavior

Focus is not set on the first textbox or control on loading the form.
Expected behavior

Focus should be set on the first textbox or component on loading the form. A way to set tabindex would be helpful.
Minimal reproduction of the problem with instructions

Open any of the examples, focus is not set on first textbox.
What is the motivation / use case for changing the behavior?

I would like auto focus on the first control on the form
Please tell us about your environment:

  • Angular version: 2.0.X

    Angular 4
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

  • Node (for AoT issues): node --version =

question

Most helpful comment

just pass true to the focus property:

    {
      key: 'text',
      type: 'input',
      focus: true,
      ...
    },

All 3 comments

just pass true to the focus property:

    {
      key: 'text',
      type: 'input',
      focus: true,
      ...
    },

just pass true to the focus property:

    {
      key: 'text',
      type: 'input',
      focus: true,
      ...
    },

Hi @aitboudad can you point me to the code line where the focus is actually set on the element? I mean, how is the field.focus=true converted to the actual focus on the form element?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ugogiordano87 picture ugogiordano87  路  4Comments

mohammedzamakhan picture mohammedzamakhan  路  4Comments

sampow picture sampow  路  4Comments

wpcfan picture wpcfan  路  3Comments

shohrukh92 picture shohrukh92  路  4Comments