-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Allow update input labels with HTML #3996
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
Conversation
|
Note: I only include |
|
Thanks @JohnCoene, would you mind looking into the test failures (and fixing them)? |
|
@cpsievert I believe it's good now. |
srcts/src/utils/index.ts
Outdated
| const emptyLabel = | ||
| Array.isArray(labelContent.html) && labelContent.html.length === 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this check might also now need to check for empty string? I noticed that this PR will break this "clear label" feature:
library(shiny)
ui <- fluidPage(
checkboxInput("id", label = "foo")
)
server <- function(input, output, session) {
updateCheckboxInput(inputId = "id", label = character(0))
}
shinyApp(ui, server)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good catch. Do we still need Array.isArray check? I'm not sure what's for to be honest; could we/can we pass a vector of length greater than 1 to label?
Asking because I wonder if it can't be simplified to just labelContent.html.length == 0 since "".length == 0 is true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I believe we can. Done in 6b97b63
It does make me realize that, with this PR updateFooInput(label = "") will now display:none the label container, which feels more like a feature than a bug
|
@JohnCoene I noticed #3996 (comment) when having a look into modifying one of our testing apps to account for this feature. I've got a start on that here rstudio/shinycoreci#262 and it'd be awesome if you wanted to review/fix/improve that test app. |
|
Is there anything else I c an do on this PR? |
|
Thanks @JohnCoene, please add a NEWS item, then this should be good to merge. That said, it'd also be great to update our cd shinycoreci/inst/apps/158-input-labels
R -e "shiny::runTests()"Screenshot differences are to be expected -- as long as the screenshot changes look good locally and there are no other failures than we can merge that PR as well |
…ude it in the message (#4237)
* Follow up to #3996: fix front-end checkbox label updating logic * More descriptive name
* Close #4239: fix front-end action button label updating logic (follow up to #3996) * Update news * Use a separator instead of putting markup in attributes * `yarn build` (GitHub Actions) * Address feedback * Cleanup * Refactor into a single method to split icon/label * `yarn build` (GitHub Actions) * Better naming * Add some padding to the separator * Add some unit tests for R logic * Update NEWS.md * Update NEWS.md * Update NEWS.md * Update NEWS.md * Increase backcompat (keep same R structure when no icon is provided) * Refine comment --------- Co-authored-by: cpsievert <cpsievert@users.noreply.github.com>
* main: (32 commits) Revert the addition of spacing between `icon` and `label` in `actionButton()` (#4248) Restrict `icon`/`label` separator spacing to `actionButton()` (#4247) Fix front-end action button label updating logic (#4242) Update news Properly handle undefined value for input subscribe callback (#4243) Start new version (#4241) v1.11.0 release candidate (#4232) Follow up to #3996: fix front-end checkbox label updating logic (#4238) feat(InputBinding): subscribe callback now supports event priority (#4211) Follow up to #3996 when label is unspecified (i.e., NULL), don't include it in the message (#4237) Run routine (#4234) chore: #4175 update jquery-ui to 1.14.1 (#4205) Update jQuery to 3.7.1 (#3969) Fix 404 in example 08_html (shiny.min.css) (#4221) Follow up to #3870: fix location of news item (#4233) Bugfix for error found in tests (#3870) Allow update input labels with HTML (#3996) Adds mirai to documentation (#4230) family->given for R Core authorship (#4222) fix(renderPlot): get interactive plotting working with ggplot2 v4.0 (#4228) ...
This is a suggestion to fix #3995.
.html()client-side (instead of.text())NULLif not we convert to character