Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Added title prop to dcc.Link #768

Merged
merged 10 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/components/Link.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -70,6 +70,7 @@ export default class Link extends Component {
style={style}
href={href}
onClick={e => this.updateLocation(e)}
title={title}
>
{this.props.children}
</a>
Expand Down Expand Up @@ -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
*/
Expand Down
26 changes: 26 additions & 0 deletions tests/integration/link/test_title_prop.py
Original file line number Diff line number Diff line change
@@ -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!"