Tapestry
  1. Tapestry
  2. TAPESTRY-195

Cannot disable auto-focus feature in ValidField

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 3.0
    • Fix Version/s: 4.1
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Operating System: MacOS X
      Platform: Macintosh

      Description

      The method addSelect(IRequestCycle) (line 131) adds JavaScript code to the body
      in order to automatically select and focus the ValidField. Though this feature
      is very nice it would be useful if there was a way to disable it. For example
      let's assume a rather long page where the form is located at the end of the
      page. The current implementation causes the browser to jump to the end of the
      page and therefore hide the beginning of the page. A simple solution might be to
      add a parameter to ValidField that triggers the code generation. But if you have
      many ValidFields in a form this solution isn't very convenient. Personally I
      would say that this "option" belongs to the Form component but then ValidField
      needs to talk to the Form component in some way. If you like I could develop a
      solution myself and present it afterwards?

        Activity

        Hide
        Jesse Kuhnert added a comment -

        ValidField is now gone as of 4.1. From the documentation of the Form component I see a focus="true/false" parameter. If this doesn't handle what you were thinking let me know and I'll re-open.

        Show
        Jesse Kuhnert added a comment - ValidField is now gone as of 4.1. From the documentation of the Form component I see a focus="true/false" parameter. If this doesn't handle what you were thinking let me know and I'll re-open.
        Hide
        Daniel Gredler added a comment -

        Oh I can wait, I was just wondering about the status. Thanks for the update.

        Show
        Daniel Gredler added a comment - Oh I can wait, I was just wondering about the status. Thanks for the update.
        Hide
        Jesse Kuhnert added a comment -

        If you can bear the wait, I don't think there's a single line of js that won't be touched in the 4.1 release. (maybe not everything, but I'm guessing 90%)

        Show
        Jesse Kuhnert added a comment - If you can bear the wait, I don't think there's a single line of js that won't be touched in the 4.1 release. (maybe not everything , but I'm guessing 90%)
        Hide
        Daniel Gredler added a comment -

        Are there any updates on this? Is this going to be fixed in a 3.0.4 or in 4.1?

        On some pages I have a form divided up into different tabs. The background tabs are hidden using CSS (display:none). Sometimes tapestry generates JavaScript that tries to focus fields that are hidden on these background tabs, which causes errors.

        On some pages I have the issue described above, where the page automatically scrolls down and skips the intro section above the form.

        Finally, a somewhat related issue is that all of this is done in a function that overwrites window.onload, so any custom window.onload functionality is lost. It'd be nice if you used something like this (http://simon.incutio.com/archive/2004/05/26/addLoadEvent):

        function addLoadEvent(func)
        {
        var oldonload = window.onload;
        if (typeof window.onload != 'function')

        { window.onload = func; }

        else {
        window.onload = function()

        { oldonload(); func(); }

        }
        }

        Show
        Daniel Gredler added a comment - Are there any updates on this? Is this going to be fixed in a 3.0.4 or in 4.1? On some pages I have a form divided up into different tabs. The background tabs are hidden using CSS (display:none). Sometimes tapestry generates JavaScript that tries to focus fields that are hidden on these background tabs, which causes errors. On some pages I have the issue described above, where the page automatically scrolls down and skips the intro section above the form. Finally, a somewhat related issue is that all of this is done in a function that overwrites window.onload, so any custom window.onload functionality is lost. It'd be nice if you used something like this ( http://simon.incutio.com/archive/2004/05/26/addLoadEvent): function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } }
        Hide
        Howard M. Lewis Ship added a comment -

        Actually, I see this as a property of the IValidationDelegate, and more of the logic should move there. In fact, I've been wanting to implement a smarter bit of logic that would "choose" the field to move to as:

        • The first field in error
        • The first required field
        • The first field rendered
          In that order of priority.
        Show
        Howard M. Lewis Ship added a comment - Actually, I see this as a property of the IValidationDelegate, and more of the logic should move there. In fact, I've been wanting to implement a smarter bit of logic that would "choose" the field to move to as: The first field in error The first required field The first field rendered In that order of priority.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development