Skip to content

Radio button value does not work correctly with falsy values #10195

Closed
@tofesath

Description

@tofesath

Bug, feature request, or proposal:

Radio button component of value does not work correctly, when contains some falsy values: 0, '', false. When you click some falsy value in row. Second option get focus, but is not checked.

What is the expected behavior?

Option should be checked when contains some falsy value.

What is the current behavior?

When I clicked some falsy value in row. Second option get focus, but is not checked.

What are the steps to reproduce?

editor: https://stackblitz.com/edit/angular-h3gkag
app url: https://angular-h3gkag.stackblitz.io

What is the use-case or motivation for changing an existing behavior?

It is normal use case add a value some falsy value.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Tested on Angular 5.2.3/Material 5.2.1, all browsers

Is there anything else we should know?

I think, that problem is in the file below. Check loose equality evalute how false.
https://github.com/angular/material2/blob/master/src/lib/radio/radio.ts#L581

and this condition in same file is never execution.
https://github.com/angular/material2/blob/master/src/lib/radio/radio.ts#L588

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions