Skip to content

Commit a899b94

Browse files
committed
Support clearing of values programmatically
1 parent e46d600 commit a899b94

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

shiny/ui/_input_update.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ def update_date(
474474
475475
Note
476476
----
477-
You cannot update the value of a date input to `None` or an empty string.
477+
A special value of `""` (an empty string) can be used to clear the value, min, and
478+
max.
478479
479480
See Also
480481
--------
@@ -489,7 +490,19 @@ def update_date(
489490
"min": _as_date_attr(min),
490491
"max": _as_date_attr(max),
491492
}
492-
session.send_input_message(id, drop_none(msg))
493+
494+
msg = drop_none(msg)
495+
496+
# Handle the special case of "", which means the value should be cleared
497+
# (i.e., go from a specified date to no specified date)
498+
if value == "":
499+
msg["value"] = None
500+
if min == "":
501+
msg["min"] = None
502+
if max == "":
503+
msg["max"] = None
504+
505+
session.send_input_message(id, msg)
493506

494507

495508
@add_example()

0 commit comments

Comments
 (0)