Open yringler opened 4 years ago
@yringler, thanks. Can you say more about what this is protecting against? When does the href-to document handler picks up and reacts to a click event when it shouldn't? Perhaps you could add a test?
It's picking up a click on a component which extends the ember linkto component. After the ember linkto finishes navigation, the handler from href-to is hit.
I don't have time to look into it further, unfortunately. For now we're just using my fork (I love yarn (which supports specifying a github url/branch!).
On further review, it looks like this is related to https://github.com/intercom/ember-href-to/blob/36c2fa8793a010e3abfa09f5a98d16cbb348317a/addon/href-to.js#L58. ~~We check in that method if click came from a link component, but not if it came from a component which inherits from link.
I'll either switch our code to using link component directly, or update the PR~~
Edit: when I click on a link-to, by the time the handler is running the link to doesn't exist anymore (navigation already happened), and the check this.applicationInstance.lookup('-view-registry:main')[id]
returns undefined
.
In our project, sometimes navigation would end up where we didn't expect. It turns out that sometimes the href-to document handler picks up and reacts to a click event when it shouldn't. Testing that the element being responded to still exists in the DOM fixed it for us.