Tapestry
  1. Tapestry
  2. TAPESTRY-1417

CSS classes on text input fields are discarded when field is in error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.4
    • Fix Version/s: 5.0.6
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      The TextField, TextArea and PasswordField components (all children of AbstractTextField) accept a "class" attribute as an informal parameter. This is rendered correctly when the component is rendered normally.

      However when the field has a validation error the ValidationDecorator will set class="t-error" before the informal attributes are added. This prevents any user supplied classes being rendered.

      ValidationDecorator works correctly if the class attribute has already been written (it adds t-error it that case), the issue is that the AbstractTextField calls the decorator before the informal attributes are rendered.

      I'm not sure of the best way to ensure the decorator is called after the informal parameters. The options I see are
      a) remove the RenderInformals mixin from AbstractField & call renderInformalParameters explicitly
      -> downside is other children of AbstractField also have to explicitly deal with informal parameters
      b) make class an explicit parameter
      -> downside is that it has to be added to attributes explicitly somewhere
      c) move the validation render & decorate to the BeforeRenderTemplate phase
      -> which feels a bit like a hack

      I think option (a) is probably best.....
      (happy to supply patch for whichever approach)

        Activity

        Ben Sommerville created issue -
        Ben Sommerville made changes -
        Field Original Value New Value
        Affects Version/s 5.0.4 [ 12312381 ]
        Fix Version/s 5.0.4 [ 12312381 ]
        Hide
        Howard M. Lewis Ship added a comment -

        I've resolved this by directly invoking ComponentResources.renderInformalParameters() before allowing the ValidationDelegate to opoerate (via its renderInside() method). This fixes the timing so that the delegate can modify the CSS class, merging its change with any provided by an informal parameter.

        Show
        Howard M. Lewis Ship added a comment - I've resolved this by directly invoking ComponentResources.renderInformalParameters() before allowing the ValidationDelegate to opoerate (via its renderInside() method). This fixes the timing so that the delegate can modify the CSS class, merging its change with any provided by an informal parameter.
        Howard M. Lewis Ship made changes -
        Fix Version/s 5.0.6 [ 12312544 ]
        Assignee Howard M. Lewis Ship [ hlship ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12402054 ] Default workflow, editable Closed status [ 12569178 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12569178 ] jira [ 12590437 ]

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Ben Sommerville
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development