Skip to content

Commit

Permalink
Fix stale event listener when using MatTopAppBarFixed in a function c…
Browse files Browse the repository at this point in the history
…omponent
  • Loading branch information
ncpenke committed Mar 14, 2022
1 parent 1bfb89d commit b086652
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions material-yew/src/top_app_bar_fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl Component for MatTopAppBarFixed {

fn view(&self, ctx: &Context<Self>) -> Html {
let props = ctx.props();

html! {
<mwc-top-app-bar-fixed
centerTitle={bool_to_option(props.center_title)}
Expand All @@ -73,6 +74,12 @@ impl Component for MatTopAppBarFixed {
}
}

fn changed(&mut self, ctx: &Context<Self>) -> bool {
// clear nav listener in case a new callback was registered
self.nav_listener = None;
true
}

fn rendered(&mut self, ctx: &Context<Self>, _first_render: bool) {
let props = ctx.props();
if self.nav_listener.is_none() {
Expand Down

0 comments on commit b086652

Please sign in to comment.