-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
whole element hidden instead of element within label #153
Comments
Hm I know exactly why this happens, but unfortunately I can't think of a proper fix. I'll explain. When you want to show/hide/enable/disable/etc an element using shinyjs, what shinyjs does is perform that action on the element you called BUT it also searches up the DOM tree to see if this element is inside a Shiny input container, and if it is, then the action is performed on the entire shiny input container. The reason this has to happen is because for many shiny inputs, the actual ID is not the correct HTML element that you want to hide. Shiny constructs a container around the input that includes other things, and you want the entire input container to get hidden. For example, this is the HTML generated from the select input in your code: If you look, in that HTML there is a tag with an id of But in your case, you're trying to hide another element within the input, so it's an edge case where this behaviour is not desireable that has not come up yet. I can't think of any good way to automatically know when I should hide the entire container and when I should not. I'm not sure if there is a possible way to know. I'll think about it some more. If anyone has anything to contribute or any questions, feel free! |
After some investigation, it seems like I might have a solution. It's possible that every shiny input has a class of |
I see and was already expecting something like this. I was also toying a little with "selector" but wasn't able to get the desired result, my gut feeling tells me it should be doable with selector here? In general. What about giving the user an extra option "findContainer" which defaults to TRUE? |
Even if you use a selector, I purposely always look up to see if there's an input container. What you want to do is strictly not possible currently (unless you want to create the label outside of the select input, and use css to make it look like it's inside...) I did briefly think about adding such a parameter, but luckily I found the shiny-bound-input class which shows some promise. In general I'm very hesitant adding a new parameter and only want to do it if it's absolutely essential. Adding a new parameter will break the existing symmetry between hide/show/toggle, because it would have to go at the end of the parameter list (to not break existing people's code), which means that the |
Makes perfect sense. I guess adding a parameter shoud be the last solution. If shiny-bound-input works, great! Looking forward to it. Thanks again for a great package! |
@fabiangehring I looked into this some more and did find a way to stop the current behaviour, so that only when you're trying to shoe/hide an actual shiny input it would search up the tree and hide the entire input container. So something like this would work:
However, in your specific case, it would still hide the entire input, because an Technically it's possible to say "only if this element is an input BUT if it's not a button or a link, then search for the input container" but that's getting too assumptious and I'm not comfortable implementing such logic. I'm ok with getting non intended behaviour when placing an input inside an input. |
That's great. For my case it's perfectly fine to do it with tags$a. Thank you very much. |
In the following minimal example the complete selectizInput is hidden when klicked on the link (instead of only the link in the label).
Am I missing something here?
The text was updated successfully, but these errors were encountered: