UI Push to update texarea causes incomplete text input in another widget to

I have a simple UI for a chat interface which has a text area to display a chat session text, and another for the user to type input.

I refresh the text area from the server side via a background UI push. This works fine,

However, if the user is typing someting in the second text input box, that seems to get cleared away due to the UI.push();

Since the user has not submitted the text, I cant send it as part of the the push() to re-populate the input box.
I did set immediate on the user entry text input though, so not sure if the backend can retrieve the value.

Any suggestions ?

Update :- I added a text changed listener and somehow this seems to have helped, but I am still in a positiom where the PUSH from the server cause the client side half filled text input box to be out of sync.

So for example, if a person is typing while there is PUSH, I need to scroll the textarea which works, but then I need to set the cursor position of the text input box back to the last character … and this causes issues, as the server only knows about the text the user entered a few seconds earlier, so the cursor jumps back in the text input box.
Somtimes, the text input box gets totally cleared.

What I want is a clean way for only one UI component to be refereshed on the screen while keeping the others state totally as it is on the client.

Why you need to call push() explicitly. In normal cases you should not do that. I.e. you should just enable push with @Push annotation. And after that update individual components in UI.access( … ).

More documentation is here


Ok, thanks. I believe the problem was that I was calling push outside the UI.access, and then also trying to set the cursor position in the text input, after setting it in the text area (to scroll to the end with the updated text)

Now I simply set the cursor position in the text area, and set focus back to the text input (when I need to update the text area), and this seems to work fine.