1
0
mirror of https://github.com/flarum/core.git synced 2025-07-16 14:26:25 +02:00

fix: support 3digit hex color input (#3706)

This commit is contained in:
IanM
2022-12-12 10:14:59 +00:00
committed by GitHub
parent 0eff1f6b2d
commit 07f8b6161a

View File

@ -10,6 +10,11 @@ export default class ColorPreviewInput extends Component {
attrs.type ||= 'text';
// If the input is a 3 digit hex code, convert it to 6 digits.
if (attrs.value.length === 4) {
attrs.value = attrs.value.replace(/#([a-f0-9])([a-f0-9])([a-f0-9])/, '#$1$1$2$2$3$3');
}
return (
<div className="ColorInput">
<input className={classList('FormControl', className)} id={id} {...attrs} />