diff --git a/packages/dnb-eufemia/src/components/input-masked/InputMaskedHooks.js b/packages/dnb-eufemia/src/components/input-masked/InputMaskedHooks.js index e28590a2633..4d7096e0112 100644 --- a/packages/dnb-eufemia/src/components/input-masked/InputMaskedHooks.js +++ b/packages/dnb-eufemia/src/components/input-masked/InputMaskedHooks.js @@ -12,6 +12,7 @@ import { import { isTrue, dispatchCustomElementEvent, + extendPropsWithContext, } from '../../shared/component-helper' import { safeSetSelection } from './text-mask/createTextMaskInputElement' @@ -482,21 +483,19 @@ const useNumberMaskParams = () => { const decimalSymbol = handleDecimalSeparator(locale) if (isTrue(as_number) || isTrue(as_percent)) { - number_mask = { + number_mask = extendPropsWithContext(number_mask, null, { decimalSymbol, thousandsSeparatorSymbol, - ...number_mask, - } + }) } else if (as_currency) { - currency_mask = { + currency_mask = extendPropsWithContext(currency_mask, null, { decimalSymbol, thousandsSeparatorSymbol, currency: getCurrencySymbol( locale, typeof as_currency === 'string' ? as_currency : null ), - ...currency_mask, - } + }) } } diff --git a/packages/dnb-eufemia/src/components/input-masked/__tests__/InputMasked.test.tsx b/packages/dnb-eufemia/src/components/input-masked/__tests__/InputMasked.test.tsx index 80a65cd83d0..23d1abc73b7 100644 --- a/packages/dnb-eufemia/src/components/input-masked/__tests__/InputMasked.test.tsx +++ b/packages/dnb-eufemia/src/components/input-masked/__tests__/InputMasked.test.tsx @@ -1018,6 +1018,36 @@ describe('InputMasked component as_number', () => { expect(document.querySelector('input').value).toBe('12 345,6') }) + it('will not overwrite decimalSymbol when undefined was given', () => { + const { rerender } = render( + + ) + + expect(document.querySelector('input').value).toBe('12|345:67') + + rerender( + + ) + + expect(document.querySelector('input').value).toBe('12 345,67') + }) + it('should merge "mask_options" properties', () => { render(