From 77f49f8c2241f454c90ae950f5b8364d92c2a401 Mon Sep 17 00:00:00 2001
From: Eryk Mika <eryk.mika@wpdesk.eu>
Date: Thu, 6 Mar 2025 15:30:28 +0100
Subject: [PATCH] fix: NumberWithUnit error handling

---
 src/NumberWithUnit/NumberWithUnit.jsx | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/NumberWithUnit/NumberWithUnit.jsx b/src/NumberWithUnit/NumberWithUnit.jsx
index 2745f92..b4853af 100644
--- a/src/NumberWithUnit/NumberWithUnit.jsx
+++ b/src/NumberWithUnit/NumberWithUnit.jsx
@@ -4,7 +4,13 @@ import {useState} from "react";
 export default function NumberWithUnit({label, onChange, value, className}) {
 
 	const splitValues = function (fontSize) {
+
+		if( !fontSize ) {
+			return {size: "0", unit: "px"};
+		}
+
 		const match = fontSize.match(/^(\d+)([a-z%]+)$/i);
+
 		if (!match) {
 			return {size: "16", unit: "px"};
 		}
-- 
GitLab