Fix Taskbar not auto stashing from multi instance menu

This change addresses an issue where touching the bottom of the screen would result in the dismissal of the multi instance menu, but leave the taskbar in a state that it would not auto stash. This is because the view was being removed through another way leading to taskbar being in a bad state. Now when the view is removed, the taskbar is correctly reset.

Fix: 380304394
Bug: 315989246
Test: Manually launch the menu then tap the bottom of the screen. Ensure that taskbar eventually auto stashes.
Flag: com.android.launcher3.enable_multi_instance_menu_taskbar
Change-Id: Ie6bae803a42cf0bcd0ff6362473a63cb22a841eb
diff --git a/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt b/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt
index c0c2a02..50ada18 100644
--- a/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt
@@ -130,6 +130,22 @@
                 onOutsideClickListener,
                 controllers,
             )
+
+        // If the view is removed from elsewhere, reset the state to allow the taskbar to auto-stash
+        taskbarShortcutAllWindowsView.menuView.rootView.addOnAttachStateChangeListener(
+            object : View.OnAttachStateChangeListener {
+                override fun onViewAttachedToWindow(v: View) {
+                    return
+                }
+
+                override fun onViewDetachedFromWindow(v: View) {
+                    controllers.taskbarAutohideSuspendController.updateFlag(
+                        FLAG_AUTOHIDE_SUSPEND_MULTI_INSTANCE_MENU_OPEN,
+                        false,
+                    )
+                }
+            }
+        )
     }
 
     /**
@@ -214,7 +230,6 @@
                 FLAG_AUTOHIDE_SUSPEND_MULTI_INSTANCE_MENU_OPEN,
                 false,
             )
-            controllers.taskbarStashController.updateAndAnimateTransientTaskbar(true)
             taskbarOverlayContext.dragLayer?.removeView(menuView.rootView)
             taskbarOverlayContext.dragLayer.removeTouchController(this)
         }