Search code examples
formsvalidationconstraintsorbeon

In Orbeon Forms, why is focus set to the first Input Field instead of the first field?


In Orbeon Forms 4.7, I have a form in which the first two fields are both required. They are:

  1. A Dropdown Menu
  2. An Input Field

When I run the form in Form Runner, focus is set to the Input Field. In other words, the cursor is in that field. The dropdown is the first field so I select a value from it. Since the Input Field has now lost focus, the validation immediately displays an error because the Input Field is missing a value.

So the validation is telling the user that they did something wrong, when all they did is answer the first question first. This looks bad and seems like incorrect behaviour.

If I can disable this instant validation, this probably won't be an issue for me. I have another question open regarding that:

https://stackoverflow.com/questions/26289498/in-orbeon-forms-is-it-possible-to-disable-instant-validation-but-still-validate


Solution

  • Good point. I thought that on OS X, by default, dropdowns were not focusable, this unless "All controls" was selected in the preferences for "Full Keyboard Access". Thus, Orbeon Forms didn't want to set the focus on a control on which, sometimes, the focus can't be set by the browser. But:

    • This might be a bad idea, and the use case you describe supports that.
    • The default in OS X is "text boxes and lists only" (highlight mine). That doesn't include buttons, but includes dropdowns.

    So I think it would be better for Orbeon Forms to include selection controls (in addition to text fields and textareas) in the list of "focusable controls" it considers when setting the focus on the first control. I created issue #1958 to cover this.