Skip to content
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

Javascript error with the color picker unselection #4634

Closed
mdeslauriers-sigmund opened this issue Feb 18, 2019 · 3 comments
Closed

Javascript error with the color picker unselection #4634

mdeslauriers-sigmund opened this issue Feb 18, 2019 · 3 comments

Comments

@mdeslauriers-sigmund
Copy link
Contributor

Using the color picker property editor :
When the user remove the selection the model is set to null.
When the user tries to select another value after that, the condition is trying to check the "value" property for a null object. This cause the Javascript Error.
The user cannot save a new color selection

Simple fix : check for null in the condition in the onSelect method of the controller.

if ($scope.model.value.value === color) {

should be

if ($scope.model.value != null && $scope.model.value.value === color) {

Reproduction

Bug summary

See description

Specifics

* Any color picker property
* Umbraco 7.13.2
* Any browsers

Error logged in the console :

angular.min.js?cdv=296567087:63 TypeError: Cannot read property 'value' of null
    at a.ColorPickerController.$scope.onSelect (umbraco.controllers.js?cdv=296567087:11606)
    at angular.min.js?cdv=296567087:74
    at Object.d.(/umbraco/anonymous function) [as onSelect] (https://etg.local.sigmund.ca/umbraco/lib/angular/1.1.5/angular.min.js?cdv=296567087:44:33)
    at a.scope.setColor (umbraco.directives.js?cdv=296567087:8247)
    at angular.min.js?cdv=296567087:74
    at angular-mobile.js?cdv=296567087:270
    at a.$eval (angular.min.js?cdv=296567087:92)
    at a.$apply (angular.min.js?cdv=296567087:92)
    at HTMLButtonElement.<anonymous> (angular-mobile.js?cdv=296567087:269)
    at HTMLButtonElement.dispatch (jquery.min.js?cdv=296567087:3)
(anonymous) @ angular.min.js?cdv=296567087:63

Steps to reproduce

* Select a color
* Unselect the color
* Try to select a color
* The error is logged in the console

Expected result

* No Javascript error
* The user should be able to save a new color selection

Actual result

* The javascript error 
* The user cannot save a new color selection
@nul800sebastiaan
Copy link
Member

Thanks, you're absolutely right! Sorry about that.

@mdeslauriers-sigmund
Copy link
Contributor Author

No problem
Sending you a PR for this in a few minutes.

@nul800sebastiaan
Copy link
Member

Thank you, all good! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants