Tapestry
  1. Tapestry
  2. TAPESTRY-1113

Form component focus parameter not working in 4.1.1

    Details

      Description

      Regression from 4.0.x - there is no code that outputs JavaScript to tell the page which form to focus, so no form element gets the initial focus.

      Perhaps this could be done as an optional parameter to tapestry.form.registerForm(id). If multiple have focus set, last one wins? Users have to manage that to avoid ambiguity, as they do now.

        Activity

        Hide
        Greg Woolsey added a comment -

        Snapshot 4.1.1-20061017.225719-37 appears to have at least some of this code working now - it at least attempts to focus the first field.

        However, if the first focusable component is a SELECT list (in my case a custom component, but I checked and PropertySelection will do this too), you get a JavaScript error. The problem is that Tapestry emits this kind of JavaScript:

        tapestry.form.focusField('fromCurrencyList');

        which looks like this:

        focusField:function(field)

        { if (arguments.length < 1) return; field = dojo.byId(field); if (!field) return; if (field.disabled || field.clientWidth < 1) return; dojo.html.selectInputText(field); }

        ,

        however, this Dojo function is only valid for elements with selectable text, which SELECT lists don't have. For these (and probably checkboxes, radio buttons, and maybe file upload form elements) you can only call their focus() functions.

        I like the idea of selecting the text of controls that support it, but I also want other fields to have the focus some times. And the default behavior should not throw a JavaScript error of course.

        Show
        Greg Woolsey added a comment - Snapshot 4.1.1-20061017.225719-37 appears to have at least some of this code working now - it at least attempts to focus the first field. However, if the first focusable component is a SELECT list (in my case a custom component, but I checked and PropertySelection will do this too), you get a JavaScript error. The problem is that Tapestry emits this kind of JavaScript: tapestry.form.focusField('fromCurrencyList'); which looks like this: focusField:function(field) { if (arguments.length < 1) return; field = dojo.byId(field); if (!field) return; if (field.disabled || field.clientWidth < 1) return; dojo.html.selectInputText(field); } , however, this Dojo function is only valid for elements with selectable text, which SELECT lists don't have. For these (and probably checkboxes, radio buttons, and maybe file upload form elements) you can only call their focus() functions. I like the idea of selecting the text of controls that support it, but I also want other fields to have the focus some times. And the default behavior should not throw a JavaScript error of course.
        Hide
        Robert Ramírez Vique added a comment -

        I have tried this feature in IE6, but this gives some problems. Seems that IE6 doesn't understand as hidden the fields inside a hidden dialog.

        My situation is really similar to Greg's situation, I have a form, there is a hidden dojo dialog (this dialog is inside a hidden div,style=display:none, to avoid render it before dojo is executed). I get a javascript error saying that the focus cannot be set to an invisible field. Then it causes the rest of javascript code to not be executed (also the dialog).

        I supose there should be a better way to solve it (I am not an javascript expert) but maybe with a javascript try-catch will solve the problem of the javascript exception which prevents the rest of the code to be executed.

        Show
        Robert Ramírez Vique added a comment - I have tried this feature in IE6, but this gives some problems. Seems that IE6 doesn't understand as hidden the fields inside a hidden dialog. My situation is really similar to Greg's situation, I have a form, there is a hidden dojo dialog (this dialog is inside a hidden div,style=display:none, to avoid render it before dojo is executed). I get a javascript error saying that the focus cannot be set to an invisible field. Then it causes the rest of javascript code to not be executed (also the dialog). I supose there should be a better way to solve it (I am not an javascript expert) but maybe with a javascript try-catch will solve the problem of the javascript exception which prevents the rest of the code to be executed.
        Hide
        Greg Woolsey added a comment -

        For dialog fields, I use a separate form for each dialog, or at least for the visible fields, and mark only the form with visible fields as the one to set focus to (form component property).

        Show
        Greg Woolsey added a comment - For dialog fields, I use a separate form for each dialog, or at least for the visible fields, and mark only the form with visible fields as the one to set focus to (form component property).
        Hide
        Joseph Chen added a comment -

        Is this problem fixed in 4.1.1? I am using the official 4.1.1 distribution from the tapestry.apache.org website. I have the same problem as the previous poster, Robert.

        We have a Dialog that contains a form. The dialog is initially hidden as well as set to style="display:none". In IE6, I'm still seeing a error saying "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus." The error only shows up in IE6 (No problems in Firefox 1.5).

        This is a regression from the 4.0.x Tapestry + Tacos 4.0 because the code used to work fine. It's only when migrating from 4.0.x to 4.1.1 that this problem shows up.

        Show
        Joseph Chen added a comment - Is this problem fixed in 4.1.1? I am using the official 4.1.1 distribution from the tapestry.apache.org website. I have the same problem as the previous poster, Robert. We have a Dialog that contains a form. The dialog is initially hidden as well as set to style="display:none". In IE6, I'm still seeing a error saying "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus." The error only shows up in IE6 (No problems in Firefox 1.5). This is a regression from the 4.0.x Tapestry + Tacos 4.0 because the code used to work fine. It's only when migrating from 4.0.x to 4.1.1 that this problem shows up.

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Greg Woolsey
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development