Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Paper radio button names that evaluate to false can be deselected without allow-empty-selection #63

Open
Anonymous-Stranger opened this issue Jul 29, 2016 · 1 comment · May be fixed by #85

Comments

@Anonymous-Stranger
Copy link

Anonymous-Stranger commented Jul 29, 2016

Description

Paper radio button names that evaluate to false can be deselected without allow-empty-selection
This becomes significant when the name is bound to index in a template dom-repeat.

Expected outcome

It should be impossible to deselect the a radio button, even if it is the only one selected.

Actual outcome

It is possible to deselect radio buttons with name set to "0".

I think it's because the check below (in paper-radio-group.html) fails when this.selected = 0 or "0", which makes the code feel its fine to toggle the radio button.

   select: function(value) {
      \\ ...
      if (this.selected) {
       \\ ...
      }
      \\ ...

Live Demo

https://jsbin.com/pocisukaqe/edit?html,css,output
(also contains a hacky solution)

Steps to reproduce

  1. Put a paper-radio-group with a few paper-radio-buttons on a page.
  2. Set the name of the first paper radio buttons to "0", and the names of the others to any values.
  3. Open the page in a web browser.
  4. Press the first radio button. Press it again to see it is toggleable, without allow-empty-selection.
  5. Press a different radio button. Press it again to see it is not toggleable.
@raydaly
Copy link

raydaly commented Oct 14, 2016

When observing "selected" it normal returns a newValue of empty string ('') when deselected. However when the name is "0" then "0" is returned as newValue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants