mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-17 10:13:56 -05:00
Fix: Dont parse numbers with exponent as integer (#5457)
This commit is contained in:
parent
d378c861f6
commit
e5f48739a0
@ -60,4 +60,9 @@ describe('NumberComponent', () => {
|
|||||||
component.writeValue(11.1)
|
component.writeValue(11.1)
|
||||||
expect(component.value).toEqual(11.1)
|
expect(component.value).toEqual(11.1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should support scientific notation', () => {
|
||||||
|
component.writeValue(1.23456789e8)
|
||||||
|
expect(component.value).toEqual(123456789)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -37,7 +37,8 @@ export class NumberComponent extends AbstractInputComponent<number> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeValue(newValue: any): void {
|
writeValue(newValue: any): void {
|
||||||
if (this.step === 1) newValue = parseInt(newValue, 10)
|
if (this.step === 1 && newValue?.toString().indexOf('e') === -1)
|
||||||
|
newValue = parseInt(newValue, 10)
|
||||||
if (this.step === 0.01) newValue = parseFloat(newValue).toFixed(2)
|
if (this.step === 0.01) newValue = parseFloat(newValue).toFixed(2)
|
||||||
super.writeValue(newValue)
|
super.writeValue(newValue)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user