Skip to content

Commit 87b0e57

Browse files
committed
fix(VNumberInput): keep all decimals when precision is null
Intl.NumberFormat defaults maximumFractionDigits to 3 (for plain numbers) fixes #22990
1 parent 83ed8d4 commit 87b0e57

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

packages/vuetify/src/components/VNumberInput/__tests__/format.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ describe('format', () => {
3434
expect(formatNumber(1.23456, opts({ precision: 2 }))).toBe('1.23')
3535
})
3636

37+
it('keeps all decimals when precision is null', () => {
38+
expect(formatNumber(0.1234, opts({ precision: null }))).toBe('0.1234')
39+
expect(formatNumber(1234.12345678, opts({ useGrouping: 'auto', precision: null }))).toBe('1,234.12345678')
40+
})
41+
3742
it('respects minFractionDigits', () => {
3843
expect(formatNumber(1.2, opts({ minFractionDigits: 3 }))).toBe('1.200')
3944
})

packages/vuetify/src/components/VNumberInput/format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function formatNumber (val: number, options: FormatNumberOptions): string
4747
minimumFractionDigits: minFractionDigits && precision != null
4848
? Math.min(minFractionDigits, precision)
4949
: (minFractionDigits ?? precision ?? undefined),
50-
maximumFractionDigits: precision ?? undefined,
50+
maximumFractionDigits: precision ?? 20, // Intl defaults are dynamic (0, 2, 3)
5151
useGrouping: options.useGrouping,
5252
})
5353

0 commit comments

Comments
 (0)