onboarding: Fix a double lease panic caused by Onboarding::clone_on_split (#35815)

Anthony Eid created

Release Notes:

- N/A

Change summary

crates/onboarding/src/onboarding.rs | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

Detailed changes

crates/onboarding/src/onboarding.rs 🔗

@@ -565,9 +565,13 @@ impl Item for Onboarding {
         _: &mut Window,
         cx: &mut Context<Self>,
     ) -> Option<Entity<Self>> {
-        self.workspace
-            .update(cx, |workspace, cx| Onboarding::new(workspace, cx))
-            .ok()
+        Some(cx.new(|cx| Onboarding {
+            workspace: self.workspace.clone(),
+            user_store: self.user_store.clone(),
+            selected_page: self.selected_page,
+            focus_handle: cx.focus_handle(),
+            _settings_subscription: cx.observe_global::<SettingsStore>(move |_, cx| cx.notify()),
+        }))
     }
 
     fn to_item_events(event: &Self::Event, mut f: impl FnMut(workspace::item::ItemEvent)) {