Skip to content

Commit

Permalink
fixed decimal symbol property
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenMasterJacob20011 authored and lane-formio committed Jul 24, 2024
1 parent c83caf0 commit 2a7c911
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased: 4.21.2-rc.1]
### Changed
- FIO-8570: fixed decimal symbol property on number component

## 4.21.1
### Changed
- Official Release
Expand Down
2 changes: 1 addition & 1 deletion src/components/number/Number.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class NumberComponent extends Input {

const separators = getNumberSeparators(this.options.language || navigator.language);

this.decimalSeparator = this.options.decimalSeparator = this.options.decimalSeparator
this.decimalSeparator = this.options.decimalSeparator = this.component.decimalSymbol || this.options.decimalSeparator
|| this.options.properties?.decimalSeparator
|| separators.decimalSeparator;

Expand Down
18 changes: 18 additions & 0 deletions src/components/number/Number.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
comp5,
comp6,
comp7,
comp8
} from './fixtures';

describe('Number Component', () => {
Expand Down Expand Up @@ -423,6 +424,23 @@ describe('Number Component', () => {
}).catch(done);
});

it('Should not remove decimal symbol and numbers after decimal symbol when submit is pressed', (done) => {
Formio.createForm(document.createElement('div'), comp8, {}).then((form) => {
const inputEvent = new Event('input');
const numberComponent = form.getComponent('number');
const buttonComponent = form.getComponent('submit');
numberComponent.refs.input[0].value = "123-456";
numberComponent.refs.input[0].dispatchEvent(inputEvent);
setTimeout(()=>{
buttonComponent.refs.button.click();
setTimeout(()=>{
assert.equal(numberComponent.refs.input[0].value, "123-456");
done();
},200);
},200);
});
});

// it('Should add trailing zeros on blur, if decimal required', (done) => {
// const comp = _.cloneDeep(comp3);
//
Expand Down
26 changes: 26 additions & 0 deletions src/components/number/fixtures/comp8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export default {
components: [
{
"label": "Number",
"applyMaskOn": "change",
"mask": false,
"tableView": false,
"delimiter": false,
"requireDecimal": false,
"inputFormat": "plain",
"truncateMultipleSpaces": false,
"key": "number",
"type": "number",
"input": true,
"decimalSymbol": "-"
},
{
"type": "button",
"label": "Submit",
"key": "submit",
"disableOnInvalid": true,
"input": true,
"tableView": false
}
]
}
1 change: 1 addition & 0 deletions src/components/number/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export comp4 from './comp4';
export comp5 from './comp5';
export comp6 from './comp6';
export comp7 from './comp7';
export comp8 from './comp8';

0 comments on commit 2a7c911

Please sign in to comment.