Skip to content

Commit 3203b0f

Browse files
authored
Merge pull request #2896 from insistence/insistence-dev
The tabIndex parameter of Div can accept number or string type
2 parents 66d564e + 337a28a commit 3203b0f

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
88

99
- [#2881](https://github.com/plotly/dash/pull/2881) Add outputs_list to window.dash_clientside.callback_context. Fixes [#2877](https://github.com/plotly/dash/issues/2877).
1010

11+
## Fixed
12+
13+
- [#2896](https://github.com/plotly/dash/pull/2896) The tabIndex parameter of Div can accept number or string type. Fixes [#2891](https://github.com/plotly/dash/issues/2891)
14+
1115
## [2.17.1] - 2024-06-12
1216

1317
## Fixed

components/dash-html-components/scripts/generate-components.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const NUMERIC_PROPERTIES = [
5656
'cols',
5757
'colSpan',
5858
'size',
59-
'step'
59+
'step',
60+
'tabIndex'
6061
];
6162

6263
const PROP_TYPES = {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from dash import Dash, Input, Output, State, html
2+
3+
4+
def test_dt001_div_tabindex_accept_string_and_number_type(dash_duo):
5+
app = Dash(__name__)
6+
app.layout = html.Div(
7+
[
8+
html.Div(id="string-div", tabIndex="1"),
9+
html.Div(id="number-div", tabIndex=1),
10+
html.Button("string", id="trigger-string"),
11+
html.Button("number", id="trigger-number"),
12+
html.Pre(id="output-string-result"),
13+
html.Pre(id="output-number-result"),
14+
],
15+
style={"padding": 50},
16+
)
17+
18+
@app.callback(
19+
Output("output-string-result", "children"),
20+
Input("trigger-string", "n_clicks"),
21+
State("string-div", "tabIndex"),
22+
prevent_initial_call=True,
23+
)
24+
def show_div_tabindex_string_type(n_clicks, tabindex):
25+
if n_clicks:
26+
if isinstance(tabindex, str):
27+
return "success"
28+
return "fail"
29+
30+
@app.callback(
31+
Output("output-number-result", "children"),
32+
Input("trigger-number", "n_clicks"),
33+
State("number-div", "tabIndex"),
34+
prevent_initial_call=True,
35+
)
36+
def show_div_tabindex_number_type(n_clicks, tabindex):
37+
if n_clicks:
38+
if isinstance(tabindex, int):
39+
return "success"
40+
return "fail"
41+
42+
dash_duo.start_server(app)
43+
44+
dash_duo.wait_for_element("#trigger-string").click()
45+
dash_duo.wait_for_element("#trigger-number").click()
46+
dash_duo.wait_for_text_to_equal(
47+
"#output-string-result",
48+
"success",
49+
)
50+
dash_duo.wait_for_text_to_equal(
51+
"#output-number-result",
52+
"success",
53+
)

0 commit comments

Comments
 (0)