fix(color picker): when picking a color, the color picker should not be black afterwards
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2024-01-21 20:25:19 +01:00
parent b8c21c2ade
commit c7b70844c6
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 10 additions and 1 deletions

View File

@ -64,6 +64,15 @@ const emit = defineEmits(['update:modelValue'])
watch(
() => modelValue,
(newValue) => {
if (newValue === '' || newValue.startsWith('var(')) {
color.value = ''
return
}
if (!newValue.startsWith('#') && (newValue.length === 6 || newValue.length === 3)) {
newValue = `#${newValue}`
}
color.value = newValue
},
{immediate: true},

View File

@ -24,7 +24,7 @@ export default class LabelModel extends AbstractModel<ILabel> implements ILabel
super()
this.assignData(data)
if (this.hexColor !== '' && this.hexColor.substring(0, 1) !== '#') {
if (this.hexColor !== '' && !this.hexColor.startsWith('#') && !this.hexColor.startsWith('var(')) {
this.hexColor = '#' + this.hexColor
}