mirror of
https://github.com/adoyle0/thaw.git
synced 2025-02-02 16:44:15 -05:00
fix: tab component remove
This commit is contained in:
parent
1e30144292
commit
8c4c5027ee
2 changed files with 16 additions and 0 deletions
|
@ -146,6 +146,14 @@ impl TabsInjection {
|
||||||
v.push(options);
|
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 {
|
pub(crate) fn use_tabs() -> TabsInjection {
|
||||||
|
|
|
@ -22,6 +22,14 @@ pub fn Tab(
|
||||||
label,
|
label,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
on_cleanup({
|
||||||
|
let key = key.clone();
|
||||||
|
let tabs = tabs.clone();
|
||||||
|
move || {
|
||||||
|
tabs.remove_tab_options(&key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class=class_list![
|
<div class=class_list![
|
||||||
"thaw-tab", ("thaw-tab--hidden", move || key != tabs.get_key()), move || class.get()
|
"thaw-tab", ("thaw-tab--hidden", move || key != tabs.get_key()), move || class.get()
|
||||||
|
|
Loading…
Add table
Reference in a new issue