[NUI] If the view had focus when it was unparented, the focus is cleared. (#4654)
authorJoogabYun <40262755+JoogabYun@users.noreply.github.com>
Thu, 13 Oct 2022 05:18:22 +0000 (14:18 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 13 Oct 2022 08:24:40 +0000 (17:24 +0900)
When the view is unparented, the focus is not cleared.
So, when app re-add the view and SetCurrentFocusView, app do not receiving the FocusGained event.

src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
src/Tizen.NUI/src/public/Common/Layer.cs

index 8135c96..9180064 100755 (executable)
@@ -1035,6 +1035,11 @@ namespace Tizen.NUI.BaseComponents
 
         internal void RemoveChild(View child)
         {
+            // If the view had focus, it clears focus.
+            if (child == FocusManager.Instance.GetCurrentFocusView())
+            {
+                FocusManager.Instance.ClearFocus();
+            }
             // Do actual child removal
             Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
             if (NDalicPINVOKE.SWIGPendingException.Pending)
index e1d00a7..cc9629c 100755 (executable)
@@ -334,6 +334,12 @@ namespace Tizen.NUI
                 Tizen.Log.Error("NUI", "You have deleted a view that is not a child of this layer.");
                 return;
             }
+            // If the view had focus, it clears focus.
+            if (child == FocusManager.Instance.GetCurrentFocusView())
+            {
+                FocusManager.Instance.ClearFocus();
+            }
+
             Interop.Actor.Remove(SwigCPtr, View.getCPtr(child));
             if (NDalicPINVOKE.SWIGPendingException.Pending)
                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();