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

Commit eb4c98e

Browse files
authored
Added title prop to dcc.Link (#768)
* Added title prop * Added changelog entry * Adding basic test
1 parent f32a236 commit eb4c98e

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## [Unreleased]
66
### Changed
77
- [#766](https://github.com/plotly/dash-core-components/pull/766) Update from React 16.8.6 to 16.13.0
8+
- [#768](https://github.com/plotly/dash-core-components/pull/768) Added title property to dcc.Link
89

910

1011
## [1.8.1] -2020-02-27

src/components/Link.react.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class Link extends Component {
5454
}
5555

5656
render() {
57-
const {className, style, id, href, loading_state} = this.props;
57+
const {className, style, id, href, title, loading_state} = this.props;
5858
/*
5959
* ideally, we would use cloneElement however
6060
* that doesn't work with dash's recursive
@@ -70,6 +70,7 @@ export default class Link extends Component {
7070
style={style}
7171
href={href}
7272
onClick={e => this.updateLocation(e)}
73+
title={title}
7374
>
7475
{this.props.children}
7576
</a>
@@ -100,6 +101,11 @@ Link.propTypes = {
100101
* Defines CSS styles which will override styles previously set.
101102
*/
102103
style: PropTypes.object,
104+
/**
105+
* Adds the title attribute to your link, which can contain supplementary
106+
* information.
107+
*/
108+
title: PropTypes.string,
103109
/**
104110
* The children of this component
105111
*/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import pytest
2+
import dash
3+
from dash.dependencies import Input, Output
4+
import dash_core_components as dcc
5+
import dash_html_components as html
6+
7+
8+
@pytest.mark.DCC768
9+
def test_liti001_prop(dash_dcc):
10+
app = dash.Dash(__name__)
11+
app.layout = html.Div(
12+
[
13+
dcc.Link("page 1", id="link1", href="/page-1", title="This is a test title!"),
14+
dcc.Location(id="url", refresh=False),
15+
html.Div(id="content")
16+
]
17+
)
18+
@app.callback(Output("content", "children"), [Input("link1", "title")])
19+
def display_title(title):
20+
return title
21+
22+
dash_dcc.start_server(app)
23+
24+
title_exists = dash_dcc.find_element('#link1').get_attribute('title')
25+
26+
assert title_exists == "This is a test title!"

0 commit comments

Comments
 (0)