[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 8135c96611fdebf874cd630ef925ec6226e72c34..9180064611227d6ccfc87b6a9554b52e801f0cf7 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 e1d00a7cf1e9d78260711b9b63baacecf3703763..cc9629c4a58d9cc14abde8b1652bdcaf94b56097 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();