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

Button target is not respected #779

Closed
debjan opened this issue Nov 23, 2021 · 4 comments
Closed

Button target is not respected #779

debjan opened this issue Nov 23, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@debjan
Copy link

debjan commented Nov 23, 2021

  • dash version: 2.0
  • dash-bootstrap-components version: 1.0

Button with target does not seem to be respected, i.e.:

dbc.Button(
    # ...
    target='_blank',
    # ...
)
@tcbegley
Copy link
Collaborator

Thanks for raising this @debjan, have reproduced the issue so will look into it and try to make a fix.

In the meantime you can use a html.A and add Bootstrap classes to it.

import dash_bootstrap_components as dbc
from dash import Dash, html

app = Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])

app.layout = dbc.Container(
    html.A(
        "Click here",
        target="_blank",
        href="/test",
        className="btn btn-primary",
    ),
    class_name="p-5",
)

if __name__ == "__main__":
    app.run_server(debug=True)

@tcbegley tcbegley added the bug Something isn't working label Nov 24, 2021
@tcbegley
Copy link
Collaborator

This has been resolved in the latest version of dash-bootstrap-components

pip install -U dash-bootstrap-components

@picousse
Copy link

Is this solved?
I just updated to dash-bootstrap-components == 1.1.0
And it doesn't work.

It does work for external link, but it doesn't for internal links:

                dbc.Col(
                    dbc.ButtonGroup([
                        create_button_with_icon(
                            color="secondary",
                            icon_class="bi-cloud",
                            text="SalesForce",
                            href="https://igoogle.com",
                            target="_blank"
                        )
                    ])
                ),
                dbc.Col(
                    dbc.ButtonGroup([
                        create_button_with_icon(
                            color=reachout_color,
                            icon_class="bi bi-megaphone-fill",
                            text=reachout_text,
                            href=f"/test?request_id={request_id}",
                            target="_blank")
                    ]), style={"textAlign": "left"}
                ),

@tcbegley
Copy link
Collaborator

Hi @picousse

It does work for external link, but it doesn't for internal links:

An internal link is one which intercepts the default browser behaviour of following a link and updates the address bar while staying on the same page and notifying Dash of the change. As a result, it doesn't make sense to have an internal link that opens in a new tab, as the page must be loaded from scratch as it would be for an external link. As a result, the target prop will only have an effect if the Button is being used as an external link.

This is documented in the docstring for target, but if you have suggestions for how we could make this behaviour clearer to users I'm certainly interested to hear it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants