Skip to content

Commit

Permalink
fix(kit): Number rejects the first time input of full width digits (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbarsukov authored Jan 26, 2024
1 parent 34a12fc commit c416884
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/kit/src/lib/masks/number/number-mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export function maskitoNumberOptionsGenerator({
isNegativeAllowed: min < 0,
}),
preprocessors: [
createFullWidthToHalfWidthPreprocessor(),
createInitializationOnlyPreprocessor({
decimalSeparator,
decimalPseudoSeparators: validatedDecimalPseudoSeparators,
Expand All @@ -89,7 +90,6 @@ export function maskitoNumberOptionsGenerator({
postfix,
}),
createAffixesFilterPreprocessor({prefix, postfix}),
createFullWidthToHalfWidthPreprocessor(),
createPseudoCharactersPreprocessor({
validCharacter: CHAR_MINUS,
pseudoCharacters: pseudoMinuses,
Expand Down
21 changes: 21 additions & 0 deletions projects/kit/src/lib/masks/number/tests/number-mask.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,25 @@ describe('Number (maskitoTransform)', () => {
});
});
});

describe('should transform full width number to half width', () => {
describe('at any time', () => {
it('at the 1st time (after initialization)', () => {
const options = maskitoNumberOptionsGenerator({
thousandSeparator: '_',
});

expect(maskitoTransform('12345', options)).toBe('12_345');
});

it('at the 2nd time (after initialization)', () => {
const options = maskitoNumberOptionsGenerator({
thousandSeparator: '_',
});

maskitoTransform('12345', options);
expect(maskitoTransform('12345', options)).toBe('12_345');
});
});
});
});

0 comments on commit c416884

Please sign in to comment.