From 93707d760886c79aa8d95dc1d500f57751c4e9e9 Mon Sep 17 00:00:00 2001 From: mdanse Date: Tue, 29 Dec 2020 09:20:43 +1100 Subject: [PATCH] Fix issue with the HTML5 color widget defaulting to black for named colors The HTML5 color input only works with long hexadecimal color notation. When converting a Color object to string, the colour package will automatically convert to the smallest possible web format including named colors and short hex notation, resulting in the default black color in the color widget. This change forces the value to be written in long hex format. --- wtforms_components/fields/color.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wtforms_components/fields/color.py b/wtforms_components/fields/color.py index bb2cc37..6f853eb 100644 --- a/wtforms_components/fields/color.py +++ b/wtforms_components/fields/color.py @@ -19,7 +19,7 @@ def _value(self): if self.raw_data: return self.raw_data[0] if self.data: - return str(self.data) + return str(self.data.hex_l) else: return u''