TextEditor Focus question

I have a problem with a TextEditor.

It does not always get focus, when I click on it. Sometimes it works fine. But sometimes I have to click twice on it, in order for it to gain focus. It seems, like the first time, it gets the focus for a very short while, but immediately afterwards looses it. Then I have to click on it a second time, and then the focus stays on the TextEditor.

I have a TextButton next to the TextEditor. The TextButton is working fine. It always reacts on the very first click. Clicking twice is never necessary.

I have not done any special focus handling for the TextEditor. Maybe that is the problem? Or what could I do to solve this? I want the TextEditor to always react the first time I click on it.