-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Radio buttons and polymer: not turning boolean to false when other option is chosen #13478
Comments
How does this compare to Polymer.js? Added NeedsInfo label. |
Sure enough, the JS version also has the same problem: <!DOCTYPE html> <html> <polymer-element name="my-example"> <my-example></my-example> </body> I find it odd that the browser doesn't change a previous radio checkbox state when a new one is checked. The work-around is to listen for changes to a radio property, and manually set all the others to false. I ended up doing this just to get it to work: MyExample() { |
This comment was originally written by @sethladd Fixed in polymer.js: Polymer/polymer#291 (maybe? but does fix the issue w/ working with the shadow dom) |
@seth, yeah, it sounds like it fixes exactly this issue. |
(the bug was in MDV getAssociatedRadioButtons) Removed Library-PolymerExpressions label. |
Thanks for checking! Marking medium because we have a workaround, but it would be really nice to apply this patch :) Removed Priority-Unassigned label. |
Added this to the M8 milestone. |
Consider this code:
import 'package:polymer/polymer.dart';
@CustomTag('my-example')
class MyExample extends PolymerElement with ObservableMixin {
@observable bool blue = false;
@observable bool green = false;
@observable bool red = false;
MyExample() {
bindProperty(this, const Symbol('red'),
() => notifyProperty(this, const Symbol('favoriteColor')));
bindProperty(this, const Symbol('green'),
() => notifyProperty(this, const Symbol('favoriteColor')));
bindProperty(this, const Symbol('blue'),
() => notifyProperty(this, const Symbol('favoriteColor')));
}
String get favoriteColor {
String value = '';
if (red) {
value = 'red';
} else if (green) {
value = 'green';
} else if (blue) {
value = 'blue';
}
return value;
}
}
<!DOCTYPE html>
<polymer-element name="my-example">
<template>
<div>
Your favorite color is:
<div>
<label for="red">Red <input name="color" type="radio" id="red" value="red" checked="{{red}}"></label>
</div>
<div>
<label for="green">Green <input name="color" type="radio" id="green" value="green" checked="{{green}}"></label>
</div>
<div>
<label for="blue">Blue <input name="color" type="radio" id="blue" value="blue" checked="{{blue}}"></label>
</div>
</div>
<div>
You selected {{favoriteColor}}
</div>
</template>
<script type="application/dart" src="my_example.dart"></script>
</polymer-element>
When I run this, and select blue, I get "you selected blue". Good. When I select blue, I get "you selected green". When I open the debugger, I see that green remains true, even though I changed the radio button.
Attachment:
[Screen Shot 2013-09-21 at 10.57.14 AM.png](https://storage.googleapis.com/google-code-attachments/dart/issue-13478/comment-0/Screen Shot 2013-09-21 at 10.57.14 AM.png) (9.06 KB)
The text was updated successfully, but these errors were encountered: