Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: 3 digit hex color value in color input not supported #3706

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
Expand Down