-
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
'shiny-bound-input' class automatically added to custom Shiny input html improperly #2779
Comments
Hmmm... perhaps Shiny should not try to bind inputs that are inside of other inputs? (The same cannot be said for outputs, which do have important recursive cases) Oh, or at the very least, have a way for input bindings to opt into “protecting” their contents from further binding. |
I suppose it's possible other users could unknowingly be relying on the former? Though I'm not sure exactly how or why that would be the case. Maybe the latter is a safer option, but perhaps either is fine? This issue is something I am looking to resolve soon. If there is any way I can help with a PR for either approach let me know. |
@leonawicz, would you mind verifying if you still have this issue? I cannot reproduce this issue on my end. It would be greatly appreciated if you could share your reproducible R code with us. Reproducible Code
Created on 2020-08-05 by the reprex package (v0.3.0.9001) Rendering Results<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="application/shiny-singletons"></script>
<script type="application/html-dependencies">json2[2014.02.04];jquery[3.5.1];shiny[1.5.0.9001];bootstrap[3.4.1]</script>
<script src="shared/json2-min.js"></script>
<script src="shared/jquery.min.js"></script>
<link href="shared/shiny.css" rel="stylesheet" />
<script src="shared/shiny.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="shared/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="shared/bootstrap/accessibility/css/bootstrap-accessibility.css" rel="stylesheet" />
<script src="shared/bootstrap/js/bootstrap.min.js"></script>
<script src="shared/bootstrap/accessibility/js/bootstrap-accessibility.min.js"></script>
</head>
<body>
<div class="container-fluid"><fieldset id="myid" class="my-input-checkboxgrp">
<legend>mylabel</legend>
<ul class="my-options-group">
<li class="my-option-item">
<input type="checkbox" id="my-checkboxgroup-A" name="my-checkboxgroup-myid" value="A"></input>
<label for="my-checkboxgroup-A">A</label>
</li>
<li class="my-option-item">
<input type="checkbox" id="my-checkboxgroup-B" name="my-checkboxgroup-myid" value="B"></input>
<label for="my-checkboxgroup-B">B</label>
</li>
</ul>
</fieldset></div>
</body>
</html> |
I still get the original problem. While the browser page source shows the original HTML, when I inspect the elements in the browser console I can see how In a realistic use case a Shiny input function generates this HTML and it has an accompanying Shiny input binding in javascript for |
@leonawicz I have an idea of how to fix it but can you also tell me why the additional class causes a problem? There shouldn't be any style associated with the class. |
See also #2956 (comment) |
First crack at a fix in #2994 |
@leonawicz, please feel free to let me know if you need accessibility test. I am a screen reader user. I did not experience any noticeable challenges against screen readers when I tested the example code above. Since every each label and input is tied using |
@jooyoungseo At my workplace we are creating our own Shiny inputs that meet various accessibility requirements we have. That is the motivation for widgets like in this example, but no, the additional injection of shiny-bound-input classes on internal elements does not cause an accessibility issue. It causes other app design and management issues. On that topic, @jcheng5 , it becomes necessary at a minimum to make sure any internal reactive input It also causes inconveniences with things like bookmarking app state. If you put several checkbox groups in an app for example, suddenly there are a large number of reactive IDs being tracked that shouldn't be reactive. This can appear in a parameterized URL for example. Of course, these can be explicitly ignored by the bookmarking code, but this quickly becomes tedious and error prone providing a long list of reactive inputs, which kind of requires the person making an app and using a widget to have a level of familiarity with the internals of the widget the author had, and then to make the ad hoc accommodation uniquely in every app. Thanks for that reference. I'll take a look at the initial fix as soon as I can! :) |
@jooyoungseo If you would like to test some of our widgets with a screen reader, I would greatly appreciate that! I could always reach out to you when we have a good example app containing each of our Shiny inputs. We are trying to meet stronger accessibility guidelines with checkboxes, radio buttons, etc. We've created a handful of typical inputs so far. We're trying to adhere to best practices but we also want to know users' actual experiences. |
@leonawicz Thanks for that explanation, that totally makes sense. I would add that HTML already forbids multiple elements having the same |
Hi, I first asked this in this RStudio community forum post since I do not think it is necessarily a bug but rather by design- but it does have problematic unanticipated consequences. It doesn't feel like a feature request either. But it was suggested that I file an issue here.
For web accessibility reasons the custom Shiny input widgets I create need to meet certain requirements. Specifically, I have cases where I need to have unique
id
attributes for<input>
tags within a larger Shiny input HTML block.For example,
The
inputId
of the Shiny widget ismyid
in thefieldset
tag. Notice each individual checkbox within has an id. The problem seems to be that as soon as I give an input tag an id attribute, Shiny appends theshiny-bound-input
class to it. So when the above widget is rendered in the browser by Shiny, it not only adds that class to the top level alongsidemyid
, but also to each individual checkbox within.So a custom Shiny input like above with five options will end up with
class="shiny-bound-input"
appended in six places. I need a way to prevent these additional class additions. It doesn't happen if I remove their id attributes, but I need to have the ids.Is there a recommended way I can prevent or override this class appending behavior? The explicit and unambiguous id pairing is critical.
The text was updated successfully, but these errors were encountered: