Possible bug in MaxLength of VTextField since 6.8 to 7.0.0

I have a BIG problem right now with the MaxLength attribute of TextField!

If I write a text in a TextField with MaxLenth, then I click out (lose focus), and then tried to enter more text, html control loses MaxLength attribute completely.

In com.vaadin.terminal.gwt.client.ui.VTextField:


399    private void setMaxLength(int newMaxLength) {
400        if (newMaxLength >= 0 && newMaxLength != maxLength) {
401            maxLength = newMaxLength;
402            updateMaxLength(maxLength);
403        } else if (maxLength != -1) {
404            maxLength = -1;
405            updateMaxLength(maxLength);
406        }
407
408    }

What happens if:

  1. setMaxLength(20);
  2. setMaxLength(20);

Cold run debug:

  1. maxLength = 20; updateMaxLength(20) called.
  2. maxLength = -1; updateMaxLength(-1) called.

If I’m not wrong this removes the maxLength html attribute!

I’m not sure if this is the root cause of the problem, but for me it seems to be.

this ticket has 4 months since was filled: http://dev.vaadin.com/ticket/9940

Fixed! http://dev.vaadin.com/ticket/9940