Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use target="_blank" for anchor tags #2252

Closed
martinezdylan opened this issue Mar 29, 2024 · 3 comments
Closed

Unable to use target="_blank" for anchor tags #2252

martinezdylan opened this issue Mar 29, 2024 · 3 comments
Labels

Comments

@martinezdylan
Copy link

Bug description

It seems the GitBook renderer ignores the target attribute in anchor tags. Could we have this added? There are some "external links" where it makes sense for it to open a new tab instead of having to navigate back and reload the page again.

How to reproduce

  1. Create a link via <a href="https://google.com" target="_blank">Google</a> in any .md file in your repo rendered by GitHub
  2. Attempt to click the link in the published endpoint, the link will open in the same tab. Viewing the DOM, it looks like it gets translated & target attribute just isn't carried over.

Additional context

N/A

@SamyPesse
Copy link
Member

GitBook does not store and transform markdown into HTML directly. Instead we parse the markdown into our own document format. This document format doesn't support a target attribute on links. Links will always opens in the same tab.

Also opening links in a new tab is not a good practice for accessibility: https://it.wisc.edu/learn/make-it-accessible/develop-accessible-websites/when-to-open-links-in-a-new-tab/#:~:text=Accessible%20websites-,Accessibility%20considerations,when%20there%20is%20no%20warning.

@gavinhenderson
Copy link

@SamyPesse the link you gave also specifies exceptions to the rule.

Consider opening a link in a new tab or window in the following cases:

  • The link is on a page with embedded playable media. In this case, opening the form in a new tab or window avoids interrupting playback.
  • Leaving the page causes the user to lose their work, such as on a fillable form. In that case, we encourage adding a warning message to notify the user of how to save their data.
  • There is a checklist or instructions the user must reference in order to complete a task on the new tab or window.

It also specifies a way to overcome the accessibility issues for these exceptions, by adding a warning to the aria-label.

I think that this should be reopened as there are lots of valid cases to open in a new tab and we could allow that behaviour and maintain good accessibility practice.

@firmai
Copy link

firmai commented Sep 13, 2024

A lot of my users are complainig on docs.sov.ai that when they open my colab links, it opens in the same tab, then they open the docs.sov.ai link again and it automatically sends them back to the colab link. Is this something that can be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants