ItsJonQ / g2

✨ An experimental reimagining of WordPress components
http://g2-components.com/
MIT License
105 stars 12 forks source link

UnitInput: Improve initial unit parsing handling to better serve values like "auto" #213

Closed ItsJonQ closed 3 years ago

ItsJonQ commented 3 years ago

This update fixes the handling of values like auto for UnitInput. Previously, auto may be assigned as a unit value.

This is because of the unit parsing function as it attempts to split ${number}${unit} into [value,unit]. Since auto doesn't start with a number, the unit parser thinks that auto is the unit.

The solution was to add some validation for the initial store state, taking into consideration the cssProp, if provided.

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/itsjonq/g2/o7lv4525j
✅ Preview: https://g2-git-fix-unit-input-initial-auto.itsjonq.vercel.app