This `/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/` only matches the long format of hex colors and returns `null` for shorthand format. Change regex to `/^#?([a-f\d]{1,2})([a-f\d]{1,2})([a-f\d]{1,2})$/` should work.
This
/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/only matches the long format of hex colors and returnsnullfor shorthand format.Change regex to
/^#?([a-f\d]{1,2})([a-f\d]{1,2})([a-f\d]{1,2})$/should work.