TextChangeEvent not fired when the text is equal to the field's value


I have a TextField with TextChangeListener registered to it. The field’s value is empty. When I start typing, the TextChangeEvents are fired properly but when I start deleting what I just wrote and am about to delete the last character, the last event is not fired at all. It therefore seems that the event is not fired when the event’s text is equal to the current value of the text field.

I have also noticed that when I leave the field and the non-empty value is committed, then when I enter the field again and start deleting, the last event IS fired. So the problem only occurs when inserting and deleting the same text without committing it meanwhile.

The thing I’m trying to achieve is to enable or disable a button based on the current field’s value. If it’s empty, I’d like to disable the button and enable it otherwise. When the field is empty, the button is disabled. Then I type one character, the event is fired and the button is enabled. Then I delete the character but the button won’t get disabled again because the TextChangeEvent is not fired.

Should I file a bug or am I just missing something? Please help because I’m unable to do proper validation because of this.

Oh, I’ve just found out that there’s already a filed bug
with the exact description.

The workaround it suggests is to call setValue(e.getText()) on the text field but that’s causing the cursor to move to the last character which makes it unusable when editing in a middle of a word. Nevermind, let’s wait for 6.7.4 :slight_smile: