diff --git a/thaw/src/tabs/mod.rs b/thaw/src/tabs/mod.rs index 8d1fb12..951797e 100644 --- a/thaw/src/tabs/mod.rs +++ b/thaw/src/tabs/mod.rs @@ -146,6 +146,14 @@ impl TabsInjection { v.push(options); }); } + + pub(crate) fn remove_tab_options(&self, key: &String) { + self.tab_options_vec.update(|v| { + if let Some(index) = v.iter().position(|tab| &tab.key == key) { + v.remove(index); + } + }); + } } pub(crate) fn use_tabs() -> TabsInjection { diff --git a/thaw/src/tabs/tab.rs b/thaw/src/tabs/tab.rs index 94e3914..eaa2c49 100644 --- a/thaw/src/tabs/tab.rs +++ b/thaw/src/tabs/tab.rs @@ -22,6 +22,14 @@ pub fn Tab( label, }); + on_cleanup({ + let key = key.clone(); + let tabs = tabs.clone(); + move || { + tabs.remove_tab_options(&key); + } + }); + view! {