diff --git a/packages/core/src/components/TextField/Mask.jsx b/packages/core/src/components/TextField/Mask.jsx index 5036795eb4..64f431233b 100644 --- a/packages/core/src/components/TextField/Mask.jsx +++ b/packages/core/src/components/TextField/Mask.jsx @@ -214,7 +214,7 @@ Mask.propTypes = { */ export function unmask(value, mask) { if (!value || typeof value !== 'string') return value; - + const rawValue = value; value = value.trim(); if (mask === 'currency') { @@ -223,6 +223,8 @@ export function unmask(value, mask) { } else if (Object.keys(deliminatedMaskRegex).includes(mask)) { // Remove the deliminators and revert to single ungrouped string value = toInt(value); + } else { + return rawValue; } return value; diff --git a/packages/core/src/components/TextField/Mask.test.jsx b/packages/core/src/components/TextField/Mask.test.jsx index 43a6667ae0..f555489c93 100644 --- a/packages/core/src/components/TextField/Mask.test.jsx +++ b/packages/core/src/components/TextField/Mask.test.jsx @@ -258,7 +258,7 @@ describe('Mask', function() { describe('unmask', () => { it('returns value when mask is undefined', () => { - expect(unmask('1,234')).toBe('1,234'); + expect(unmask(' 1,234 Foo ')).toBe(' 1,234 Foo '); }); it('returns value when mask is unknown', () => {