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

Validation error for colour selected via picker #61

Closed
philclaridge opened this issue Jul 11, 2020 · 5 comments
Closed

Validation error for colour selected via picker #61

philclaridge opened this issue Jul 11, 2020 · 5 comments
Assignees

Comments

@philclaridge
Copy link

Python version
3.8

Django version
3.0.7

Package version
0.3.2 (including jscolor 2.1.1)

Browser
Safari and Chrome

Current behavior (bug description)
Validation error on admin screen "Enter a valid color."
Occurs for colour edited via picker, or default colour or colour with # previously read from database.
On deeper inspection colours selected with colour picker are displayed without a leading hash symbol. Value without leading hash then fails validation at line 16 of fields.py. (have added additional validator to intercept and confirm value to be validated has no leading hash).

When reading colour from database (that had a leading hash) the colour is now displayed without the leading hash and validation fails on save even if colour not changed.

Have run collect static to verify have latest JS.

Have recently upgraded number of other library including upgrade to Django 3.0.7

See image below.

Expected behaviour
Unchanged colour and picked colour will not cause validation error.
Leading hash preserved on entered/default colour.

image

@fabiocaccamo
Copy link
Owner

@philclaridge this is really strange. I could understand if your only case would be reading a previously stored color without the #, but default colors and colors choosen using the color picker should work fine.

I'm not able to reproduce the issue you reported. In all my tests color is always prefixed correctly by #.
Could you try to force delete of browser cache?

@fabiocaccamo
Copy link
Owner

@philclaridge any feedback?

@fabiocaccamo
Copy link
Owner

Feel free to re-open this issue if you have an useful feedback to provide.

@dryan
Copy link

dryan commented Aug 25, 2020

I believe this is an underlying issue with JSColor when a Content Security Policy doesn't allow 'unsafe-eval'. I ran into this myself and had to make an exception inside the admin area for my CSP.

@fabiocaccamo
Copy link
Owner

Thank you for the useful information.

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

No branches or pull requests

3 participants