Focus for multiple fields inside CustomField


I have created a custom component by extending CustomField. It consists of Vertical layout, which is assigned to composition root and inside layout I have a TextField for search, a readonly TextField for showing the selected value, a Table for selection and a button (shows/hides the table). The idea is that when a user types in TextField, the input is used as a search parameter for query and table is populated with first ten results from the query (we do not want to use the usual combobox with filtering because the query returns too much results).

Now my problem is the following:
At the beggining my table is hidden and when user starts typing, the table is shown and populated. Then user selects a value in the table. At this point I set the internal value of my entity (custom field represents one property of the entity), fill the TextField for selected value and hide the table.
But if user does not select any value in the table and clicks outside my custom component, there is no way for me to detect that (I would like to close the tableview at this point like in ComboBox).

So I would like to hide the table if a user has focus on any of the internal fields and clicks outside the CustomField. Is this possible? I have tried various listeners but couldn’t figure it out. My initial idea was that the CustomField would have a blur listener but it didn’t work.

The picture below shows how the component looks now