-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Widgets' inputIds behave incorrectly with spaces #2799
Comments
Spaces in IDs aren't supported. It could help if we added a check for this and throw an error if someone tries to use it. |
Yeah, it's definitely funny that including spaces works for setting ids, retrieving values, but not updating widgets, all without an error. It should definitely throw an error and be mentioned in the help pages for selectInput, numericInput, etc |
This article provides a short note regarding special JavaScript characters in input id's:
An error message would be quite helpful 👍 |
Would a pull request that threw an error on bad inputIDs be welcome? I saw a note in the docs that said anything that creates backward compatibility issues would not be welcome. Since spaces in IDs work for many scenarios, there is probably a lot of functional code out there that would no longer work if this started throwing errors. If it would be welcome, I would be open to trying if someone can point me in the direction of "these are the files that would need to change." |
We'd definitely take a look at the PR, but note that there may be some tricky stuff involved to get all the details right. We definitely don't want to break existing apps, so it would be better to throw a warning than an error. |
Is there any mention of this being unsupported in the formal documentation? I just spent the better part of a week debugging a glitchy app and finally isolated the root cause to be the use of an
How about something like |
Well hidden, but see the note here:
However, the space restriction seems to be inherited from HTML:
|
Browsers are funny like that: an ID must not contain whitespace, but if it does we'll consider the whitespace part of the ID. I strongly recommend avoiding whitespace in input IDs, but given that almost anything will work in the browser – and most if not all of our inputs will work fine with spaces in them – I don't think we should be more aggressive unless we have a strong reason to do so. (In other words, if spaces in an ID break a specific input, we should proactively avoid those issues early.) In this case, we can support input updates when spaces are involved by changing our JavaScript internals to use a CSS selector that queries by attribute value. E.g. the |
With my non-comprehensive look through Shiny documentation, it appears that the only requirement for a Shiny widget inputId is that it is a character string. However, I have discovered that if you have spaces in that character string, the updateWidget function doesn't behave properly (it basically is ignored, with no error message). My simple repro, where I change the id from "bin" to "Number of bins" documents the problem:
The text was updated successfully, but these errors were encountered: