Changes in a TextField are not usable in drag&drop

It seems changes in a TextField are not accessible with getValue in DropHandler.drop if dropping is done immediately after writing to the TextField.

Try this:

  • Write text to TextField a, don’t click anyhere, don’t press tab, enter, etc.
  • Drag some component b to some other component c
  • See what you get with a.getValue in DropHandler.drop

And then this:

  • Write text to TextField a, but this time move focus out of the TextField by pressing tab, clicking somewhere else, etc.
  • Drag b to c
  • a.getValue called in the DropHandler.drop gives the correct text

Setting a.setImmediate(true) doesn’t seem to make any difference.
Here is an example project and video: http://k2c42.dy.fi/dnd_immediate/

Is this a known bug/feature? Is there a work-around?

The reason the text is not copied when you try to drag the TextField with keyboard focus is that TextField sends the value to the server by default only when focus is lost. So when you drop the TextField the value of the server is used instead of the client and so the value is empty.

If you want that kind of really immediate sending of the text to the server then you should take a look at TextFields TextChangeEvents and save the value in each TextChangeEvent.