Closed KevinBongart closed 2 years ago
Hey @KevinBongart. You can find more info about this issue here https://github.com/heartcombo/simple_form/issues/1257. It's not really optimal but that's how it works at the moment.
TL;DR Just remove b.optional :readonly
from your configuration and use readonly
component when you need
Current behavior
I have this wrapper in my app, coming from this repo:
I'm not entirely sure how
simple_form
uses thereadonly
option, but I recently ran into an issue (on Stack Overflow) where Capybara couldn't interact with one of the two radio buttons without a JavaScript driver (such asselenium_chrome_headless
). It looks that is because the resulting HTML has areadonly="readonly"
on one of the two radio buttons, which apparently is not valid HTML.Here's the ERB code:
The
baz
field is a boolean attribute on thebar
class, and the line generates this HTML (note thereadonly
on the second input):Capybara has since then been fixed to ignore the
readonly
attributes on radio buttons, but I'm still wondering about where in the stack the issue originates, if that's an issue at all, and what I can do to work around it.Environment
Expected behavior
I believe there shouldn't be a
readonly="readonly"
attribute on the radio button unless explicitly passed in, and even then, since it's apparently not valid HTML, maybe some validation should prevent it. If you believe otherwise, I'd love to hear the rational behind it and figure out a workaround.