Skip to content

Commit 5d55504

Browse files
committed
Added logic to disallow formatting when the field is user-editable.
1 parent 885f87f commit 5d55504

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

PROPS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
| `emptied` | Set if input can be empty | Boolean | `false` | |
4040
| `fontFamily` | Custom fontFamily of the text input of the Spinner | String | System Default | |
4141
| `fontSize` | Custom fontSize of the text input of the Spinner | Number | `14` | |
42-
| `formatter` | Custom formatting of the Spinner text | Function | `null` | `(value) => { ...; return formattedValue }` |
42+
| `formatter` | Custom formatting of the Spinner text | Function | `null` | `(value) => { ...; return formattedValue }`. `editable` must be `false` |
4343
| `height` | Custom height of the Spinner | Number | `50` | |
4444
| `initialValue` | Initial value of the Spinner | String<br>Number | `0` | |
4545
| `inputStyle` | Input Style (Text number at middle) | Object | | Could overwrite other props |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Check the "[Props List](PROPS.md)" file to have the complete list of component p
145145
| `typingTime` | Time before debounce and trigger `onChange` event | Number | `750` | |
146146
| `type` | Type of spinner | String | `int` | Can be `int` or `real`/`float`... |
147147
| `value` | Controlled value of the Spinner | String<br>Number | `0` | |
148-
| `formatter` | An optional function that is called to format the value for display | Function | `null` | Should return a `string` |
148+
| `formatter` | An optional function that is called to format the value for display | Function | `null` | Should return a `string`. `editable` must be `false`. |
149149

150150
#### Screenshots
151151

src/InputSpinner.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ class InputSpinner extends Component {
494494
: ".",
495495
);
496496

497-
if (this.props.formatter !== null && typeof(this.props.formatter) === 'function') {
497+
// Only apply the formatter if the field is not user-editable
498+
if (this.props.formatter !== null && typeof(this.props.formatter) === 'function' && !this.props.editable) {
498499
return this.props.formatter(value)
499500
}
500501
else {

0 commit comments

Comments
 (0)