diff --git a/CHANGELOG.md b/CHANGELOG.md index c48cd564e..008e6330a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Changed - [#766](https://github.com/plotly/dash-core-components/pull/766) Update from React 16.8.6 to 16.13.0 +- [#768](https://github.com/plotly/dash-core-components/pull/768) Added title property to dcc.Link ## [1.8.1] -2020-02-27 diff --git a/src/components/Link.react.js b/src/components/Link.react.js index 6839bc2b9..d697fbeb8 100644 --- a/src/components/Link.react.js +++ b/src/components/Link.react.js @@ -54,7 +54,7 @@ export default class Link extends Component { } render() { - const {className, style, id, href, loading_state} = this.props; + const {className, style, id, href, title, loading_state} = this.props; /* * ideally, we would use cloneElement however * that doesn't work with dash's recursive @@ -70,6 +70,7 @@ export default class Link extends Component { style={style} href={href} onClick={e => this.updateLocation(e)} + title={title} > {this.props.children} @@ -100,6 +101,11 @@ Link.propTypes = { * Defines CSS styles which will override styles previously set. */ style: PropTypes.object, + /** + * Adds the title attribute to your link, which can contain supplementary + * information. + */ + title: PropTypes.string, /** * The children of this component */ diff --git a/tests/integration/link/test_title_prop.py b/tests/integration/link/test_title_prop.py new file mode 100644 index 000000000..54e7ebca7 --- /dev/null +++ b/tests/integration/link/test_title_prop.py @@ -0,0 +1,26 @@ +import pytest +import dash +from dash.dependencies import Input, Output +import dash_core_components as dcc +import dash_html_components as html + + +@pytest.mark.DCC768 +def test_liti001_prop(dash_dcc): + app = dash.Dash(__name__) + app.layout = html.Div( + [ + dcc.Link("page 1", id="link1", href="/page-1", title="This is a test title!"), + dcc.Location(id="url", refresh=False), + html.Div(id="content") + ] + ) + @app.callback(Output("content", "children"), [Input("link1", "title")]) + def display_title(title): + return title + + dash_dcc.start_server(app) + + title_exists = dash_dcc.find_element('#link1').get_attribute('title') + + assert title_exists == "This is a test title!"