Skip to content

Commit 2add4eb

Browse files
committed
add test
1 parent 6cb3ab0 commit 2add4eb

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

components/dash-core-components/tests/integration/calendar/test_date_picker_single.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,3 +676,43 @@ def display_date(date):
676676
), "Input should display 2021-06-23"
677677

678678
assert dash_dcc.get_logs() == []
679+
680+
681+
def test_dtps031_resize_detector(dash_dcc):
682+
"""Test that DatePickerSingle displays date if initially rendered in hidden container"""
683+
app = Dash(__name__)
684+
app.layout = html.Div(
685+
[
686+
html.Button("Unhide", id="update-btn"),
687+
html.Div(
688+
id="hidden",
689+
style={"display": "none"},
690+
children=dcc.DatePickerSingle(date="2026-02-24", id="dps"),
691+
),
692+
]
693+
)
694+
695+
@app.callback(
696+
Output("hidden", "style"),
697+
Input("update-btn", "n_clicks"),
698+
prevent_initial_call=True,
699+
)
700+
def update_date(n_clicks):
701+
return {}
702+
703+
dash_dcc.start_server(app)
704+
705+
input_element = dash_dcc.find_element(".dash-datepicker-input")
706+
initial_style = input_element.get_attribute("style")
707+
assert "width: 2px;" in initial_style
708+
709+
# Click button to unhide
710+
btn = dash_dcc.find_element("#update-btn")
711+
btn.click()
712+
time.sleep(0.5)
713+
714+
updated_style = input_element.get_attribute("style")
715+
716+
assert "width: 77px;" in updated_style
717+
718+
assert dash_dcc.get_logs() == []

0 commit comments

Comments
 (0)