From 9bd22fc6fad88c081868e48c4f480fbb15620029 Mon Sep 17 00:00:00 2001 From: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> Date: Fri, 6 Mar 2020 23:33:14 -0500 Subject: [PATCH 1/8] Added title prop --- src/components/Link.react.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Link.react.js b/src/components/Link.react.js index 6839bc2b9..de78f3e69 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 */ From b45f7e12024a423ee3d99446b2c4a507953658e8 Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Wed, 11 Mar 2020 14:23:52 -0400 Subject: [PATCH 2/8] Format changes --- src/components/Link.react.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Link.react.js b/src/components/Link.react.js index de78f3e69..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, title,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 @@ -102,7 +102,7 @@ Link.propTypes = { */ style: PropTypes.object, /** - * Adds the title attribute to your link, which can contain supplementary + * Adds the title attribute to your link, which can contain supplementary * information. */ title: PropTypes.string, From 8cc6abb0d40d79bd995793729f66b4c81346c1a3 Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Wed, 11 Mar 2020 14:28:34 -0400 Subject: [PATCH 3/8] Added changelog entry. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 31720e7e6223225990c93db92a83c6261575c003 Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Wed, 11 Mar 2020 15:55:03 -0400 Subject: [PATCH 4/8] Adding basic test --- tests/integration/link/test_title_prop.py | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/integration/link/test_title_prop.py diff --git a/tests/integration/link/test_title_prop.py b/tests/integration/link/test_title_prop.py new file mode 100644 index 000000000..13557dcec --- /dev/null +++ b/tests/integration/link/test_title_prop.py @@ -0,0 +1,32 @@ +import pytest +import dash +from dash.dependencies import Input, Output, State +import dash.testing.wait as wait +import dash_core_components as dcc +import dash_html_components as html + + +@pytest.mark.DCC768 +def test_title001_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.driver.execute_script( + ''' + return document.getElementById("link1").hasAttribute("title"); + ''' + ) + + assert title_exists + From 8e17dedf4d4555c9cfa6e214e8ac469083805851 Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Wed, 11 Mar 2020 16:04:06 -0400 Subject: [PATCH 5/8] Updated basic test --- tests/integration/link/test_title_prop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/link/test_title_prop.py b/tests/integration/link/test_title_prop.py index 13557dcec..fd4843a4d 100644 --- a/tests/integration/link/test_title_prop.py +++ b/tests/integration/link/test_title_prop.py @@ -24,9 +24,9 @@ def display_title(title): title_exists = dash_dcc.driver.execute_script( ''' - return document.getElementById("link1").hasAttribute("title"); + return document.getElementById("link1").getAttribute("title"); ''' ) - assert title_exists + assert "This is a test title!" From 804da4af0eb3db0689d5f33e8c1a6f6a45b91f95 Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Thu, 12 Mar 2020 23:54:20 -0400 Subject: [PATCH 6/8] Fixed integration test --- tests/integration/link/test_title_prop.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/integration/link/test_title_prop.py b/tests/integration/link/test_title_prop.py index fd4843a4d..1fca45dd7 100644 --- a/tests/integration/link/test_title_prop.py +++ b/tests/integration/link/test_title_prop.py @@ -1,7 +1,6 @@ import pytest import dash -from dash.dependencies import Input, Output, State -import dash.testing.wait as wait +from dash.dependencies import Input, Output import dash_core_components as dcc import dash_html_components as html @@ -11,7 +10,7 @@ def test_title001_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.Link("page 1", id="link1", href="/page-1", title="This is a test title!"), dcc.Location(id="url", refresh=False), html.Div(id="content") ] @@ -28,5 +27,4 @@ def display_title(title): ''' ) - assert "This is a test title!" - + assert title_exists == "This is a test title!" From 3de70d24a549370e0e21d7c5be73f9001dbddc5e Mon Sep 17 00:00:00 2001 From: HammadTheOne <30986043+HammadTheOne@users.noreply.github.com> Date: Fri, 13 Mar 2020 18:17:48 -0400 Subject: [PATCH 7/8] Update tests/integration/link/test_title_prop.py Co-Authored-By: alexcjohnson --- tests/integration/link/test_title_prop.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/link/test_title_prop.py b/tests/integration/link/test_title_prop.py index 1fca45dd7..729d0ccb5 100644 --- a/tests/integration/link/test_title_prop.py +++ b/tests/integration/link/test_title_prop.py @@ -6,7 +6,7 @@ @pytest.mark.DCC768 -def test_title001_prop(dash_dcc): +def test_liti001_prop(dash_dcc): app = dash.Dash(__name__) app.layout = html.Div( [ From f80f844d52fc7923a86899fe90757bfbe98c3415 Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Mon, 16 Mar 2020 17:46:05 -0400 Subject: [PATCH 8/8] Updating test --- tests/integration/link/test_title_prop.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/integration/link/test_title_prop.py b/tests/integration/link/test_title_prop.py index 729d0ccb5..54e7ebca7 100644 --- a/tests/integration/link/test_title_prop.py +++ b/tests/integration/link/test_title_prop.py @@ -21,10 +21,6 @@ def display_title(title): dash_dcc.start_server(app) - title_exists = dash_dcc.driver.execute_script( - ''' - return document.getElementById("link1").getAttribute("title"); - ''' - ) + title_exists = dash_dcc.find_element('#link1').get_attribute('title') assert title_exists == "This is a test title!"