Fix a problem with event captured in wrong element

When clicking the badge in the sidebar, all sidebar
item would disappear. We adjust the target element
when captured in the badge to prevent this.