FIX: Add bookmark-list component (PR #10451)

Moving the bookmark list into its own component to solve click binding issues for external links, because controllers are not the place for DOM manipulation!

GitHub

I would wrap this into something like this:

<div {{on "click" this.openBookmark}}>
  {{topic-link bookmark}}
</div>

And then you could refactor the component to only need this:

  @action
  openBookmark(event) {
    let link = event.target;

    if (shouldOpenInNewTab(link.href)) {
      event.preventDefault();
      openLinkInNewTab(link);
    }
  },

This is a little bit annoying and I would prefer if we could have a way to intercept at topic-link level, but that should do the job correctly, and is a lot less code than what you have.

Maybe a followup PR could be to improve topic-link to support opening in new tab.

can’t you just do:

action=loadMore

?

@jjaffeux the problem here is links appearing in the excerpt a few lines down, not the topic-link. The topic link is never an external link so that “open external links in new tab” preference will not affect them. However this could work for the wrapper around excerpt so I’ll try that!

Ah…could have sworn I tried that. Thank you!

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/bookmark-page-does-not-respect-open-all-external-links-in-new-tab-user-preference/160118/10