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

colors: add support for null or undefined values #11672

Open
alirezamirian opened this issue Mar 12, 2019 · 2 comments · May be fixed by #11673
Open

colors: add support for null or undefined values #11672

alirezamirian opened this issue Mar 12, 2019 · 2 comments · May be fixed by #11673
Assignees
Labels
P4: minor Minor issues. May not be fixed without community contributions. type: enhancement
Milestone

Comments

@alirezamirian
Copy link
Contributor

Bug or maybe enhancement request:

md-colors directive throws error when property values evaluate to null or undefined.
Handling null or undefined is particularly useful when expression is controlled by some nullable user input.

Currently it not logs an error in the console, but also fails to correctly clean previous styles when going from some value to undefined or null.

CodePen and steps to reproduce the issue:

CodePen Demo which demonstrates the issue:

Detailed Reproduction Steps:

  1. Select a color from color selection control
  2. Select none

What is the expected behavior?

md-colors should gracefully handle null or undefined. It should not log error in the console, and also it should clean previous styles when going from a valid color to null/undefined

What is the current behavior?

It logs lots of errors in the console and doesn't clean previous styles properly.

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

All use cases when values are not static strings and are dynamically evaluated and can may be nullable.

Which versions of AngularJS, Material, OS, and browsers are affected?

  • AngularJS: any (not relevant)
  • AngularJS Material: 1.1.13 (latest at the time)
  • OS: any
  • Browsers: any

Is there anything else we should know? Stack Traces, Screenshots, etc.

No

@alirezamirian alirezamirian linked a pull request Mar 12, 2019 that will close this issue
3 tasks
@Splaktar Splaktar self-assigned this Mar 13, 2019
@Splaktar Splaktar added type: enhancement for: external contributor P4: minor Minor issues. May not be fixed without community contributions. labels Mar 13, 2019
@Splaktar Splaktar added this to the 1.1.14 milestone Mar 13, 2019
@Splaktar
Copy link
Member

OK, in the CodePen demo I see "Cannot read property 'split' of null" in the console so I get that part of this report.

When I select None, you are expecting that the text turns back to black along with the background being white?

@jazdw
Copy link

jazdw commented Mar 14, 2019

I generally work around this by using something like this, not ideal obviously.

<div md-colors="accent ? {color: 'accent'} : {}">Test test</div>

@Splaktar Splaktar modified the milestones: 1.1.14, 1.1.15 Mar 18, 2019
@Splaktar Splaktar modified the milestones: 1.1.15, 1.1.16, 1.1.18, 1.1.19 Mar 29, 2019
@Splaktar Splaktar modified the milestones: 1.1.19, - Backlog May 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P4: minor Minor issues. May not be fixed without community contributions. type: enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants