Skip to content

Commit ff471fa

Browse files
authored
fix: input_date()/input_date_range() once again defaults to the _client's_ current date (#2060)
1 parent 0b9188b commit ff471fa

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5353

5454
* Fix missing session when trying to display an error duing bookmarking. (#1984)
5555

56+
* `input_date()` and `input_date_range()` once again use the client's (not the server) current date as the default `value`. (#2060)
57+
5658
* Fixed `set()` method of `InputSelectize` controller so it clears existing selections before applying new values. (#2024)
5759

5860
### Deprecations

shiny/ui/_input_date.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from htmltools import Tag, TagAttrValue, TagChild, css, div, span, tags
88

99
from .._docstring import add_example
10+
from .._namespaces import resolve_id
1011
from ..bookmark import restore_input
11-
from ..module import resolve_id
1212
from ._html_deps_external import datepicker_deps
1313
from ._utils import shiny_input_label
1414

@@ -112,13 +112,11 @@ def input_date(
112112
"""
113113

114114
resolved_id = resolve_id(id)
115-
default_value = value if value is not None else date.today()
116-
117115
return div(
118116
shiny_input_label(resolved_id, label),
119117
_date_input_tag(
120118
id=resolved_id,
121-
value=restore_input(resolved_id, default_value),
119+
value=restore_input(resolved_id, value),
122120
min=min,
123121
max=max,
124122
format=format,
@@ -233,15 +231,14 @@ def input_date_range(
233231
"""
234232

235233
resolved_id = resolve_id(id)
236-
default_start = start if start is not None else date.today()
237-
default_end = end if end is not None else date.today()
238-
restored_date_range = restore_input(resolved_id, [default_start, default_end])
234+
start, end = tuple(restore_input(resolved_id, [start, end]))
235+
239236
return div(
240237
shiny_input_label(resolved_id, label),
241238
div(
242239
_date_input_tag(
243240
id=resolved_id,
244-
value=restored_date_range[0],
241+
value=start,
245242
min=min,
246243
max=max,
247244
format=format,
@@ -257,7 +254,7 @@ def input_date_range(
257254
),
258255
_date_input_tag(
259256
id=resolved_id,
260-
value=restored_date_range[1],
257+
value=end,
261258
min=min,
262259
max=max,
263260
format=format,

0 commit comments

Comments
 (0)