Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When dateInput is set to NA by default: Warning: Couldn't coerce the 'value' argument to a date string with format yyyy-mm-dd #4149

Open
isaactpetersen opened this issue Oct 30, 2024 · 1 comment

Comments

@isaactpetersen
Copy link

System details

Output of sessionInfo():

> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] shiny_1.9.1

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.1    golem_0.5.1         dplyr_1.1.4         fastmap_1.2.0       promises_1.3.0     
 [6] shinyjs_2.1.0       digest_0.6.37       timechange_0.3.0    mime_0.12           lifecycle_1.0.4    
[11] ellipsis_0.3.2      processx_3.8.4      magrittr_2.0.3      compiler_4.3.1      rlang_1.1.4        
[16] config_0.3.2        sass_0.4.9          tools_4.3.1         geoloc_0.0.0.9500   utf8_1.2.4         
[21] yaml_2.3.10         knitr_1.48          fortunes_1.5-4      htmlwidgets_1.6.4   bit_4.5.0          
[26] pkgbuild_1.4.5      curl_5.2.3          here_1.0.1          xml2_1.3.6          pkgload_1.4.0      
[31] miniUI_0.1.1.1      withr_3.0.2         purrr_1.0.2         desc_1.4.3          fansi_1.0.6        
[36] roxygen2_7.3.2      urlchecker_1.0.1    profvis_0.4.0       xtable_1.8-4        cli_3.6.3          
[41] rmarkdown_2.28      generics_0.1.3      remotes_2.5.0       rstudioapi_0.17.1   sessioninfo_1.2.2  
[46] DBI_1.2.3           cachem_1.1.0        stringr_1.5.1       vctrs_0.6.5         devtools_2.4.5     
[51] jsonlite_1.8.9      callr_3.7.6         hms_1.1.3           bit64_4.5.2         attempt_0.3.1      
[56] testthat_3.2.1.1    jquerylib_0.1.4     glue_1.8.0          ps_1.8.1            DT_0.33            
[61] lubridate_1.9.3     stringi_1.8.4       later_1.3.2         pool_1.0.4          tibble_3.2.1       
[66] pillar_1.9.0        htmltools_0.5.8.1   brio_1.1.5          R6_2.5.1            rprojroot_2.0.4    
[71] evaluate_1.0.1      RMariaDB_1.3.2      memoise_2.0.1       renv_1.0.11         httpuv_1.6.15      
[76] bslib_0.8.0         Rcpp_1.0.13         uuid_1.2-1          shinyvalidate_0.1.3 xfun_0.48          
[81] fs_1.6.4            usethis_3.0.0       pkgconfig_2.0.3

Example application or steps to reproduce the problem

dateInput(
   inputId = ns("dob"),
   label = "What is your date of birth? (MM/DD/YYYY)",
   format = "mm-dd-yyyy",
   value = as.Date(NA))

Here is the warning it creates:

Warning: Couldn't coerce the `value` argument to a date string with format yyyy-mm-dd

Describe the problem in detail

I am trying to have a dateInput where the date is not selected by default. However, if I set value = as.Date(NA), as recommended here, it results in a warning (see above). Many other users have identified this issue (see links below):

The issue seems similar to:

Thanks in advance!

@isaactpetersen isaactpetersen changed the title When dateInput is set to NA by default: Warning: Couldn't coerce the value argument to a date string with format yyyy-mm-dd When dateInput is set to NA by default: Warning: Couldn't coerce the 'value' argument to a date string with format yyyy-mm-dd Oct 30, 2024
@nirguk
Copy link

nirguk commented Nov 11, 2024

Note to myself, this seem to be because value propogates as null, and this causes the

`data-initial-date` = value

to omit data-initial-date whereas it seems the preferred behaviour would be to repeat the text a la

`data-initial-date` = "data-initial-date" 

as this will cause the tag to be present, and the visual result is a blank field in the input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants