How to un-focus element when removing from hierarchy?

Hi. I implemented in-game window system by using UI Toolkit.

To close window, I removed the root element of the window from hierarchy (RemoveFromHierarchy() method). But after removing, it is still focused and InputSystemUIInputModule still access to it.

How to un-focus VisualElement for preventing input-interaction?

Thanks.

Found that Blur() method makes it.

1 Like

Glad you found a workaround. This sure sound like a bug that should not have occurred in the first place.

Hi Kichang-Kim. This is indeed a bug that we will fix for sure but if you’d like to submit a bug with a small repro project, it would help us track the issue. Thank you for pointing this out!

Reported as Case 1379300. I hope this help you.

Up.
Unity 2022.3.16f
This problem still exist (or again).
I reuse my elems and they didn`t unfocus automatically when were removed from parent.
Solution also invoke ele.Blur() after event DetachFromPanelEvent;