Skip to content

Commit ebac8db

Browse files
Simplify how the decimal places are set
In `v1.1.*`, whenever the options were changed, the number of decimal places for the `rawValue` was calculated based of the previous options, and not only the new given options. This was useful when two vue-autonumeric components shared the same v-model, but different options that have different values for the `rawValue` decimal places count. For instance if one of the `vue-autonumeric` component had a `decimalPlaces` option set to `2`, and another set to `5`, then when the user modified the value of one of those components, vue-autonumeric would detect a programmatic value change in the other component (since it did not come from a user interaction), and it would then use `set()` to set the new value. The first component would drop the additional decimal places when using `set()`...which in turn would make the other components aware of that new value change, and the second component would then use that new cropped value as well. However, this special decimal places management is complexifying the code quite a bit, and is not 100% effective since some use cases were difficult, if even possible, to manage. This `rawValueDecimalPlaces` *hack* is now reverted to a more sane and legible code. From now on, the user will have to explicitly declare the `rawValueDecimalPlaces` value when updating the options, if he does not want to lose the precision when switching options. Signed-off-by: Alexandre Bonneau <alexandre.bonneau@linuxfr.eu>
1 parent 9a30efb commit ebac8db

File tree

8 files changed

+2487
-1455
lines changed

8 files changed

+2487
-1455
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
## Changelog for vue-autoNumeric
22

3+
### 1.2.0
4+
+ Simplify how the `rawValue` decimal places are set
5+
+ In `v1.1.*`, whenever the options were changed, the number of decimal places for the `rawValue` was calculated based of the previous options, and not only the new given options.
6+
+ This was useful when two vue-autonumeric components shared the same v-model, but different options that have different values for the `rawValue` decimal places count.
7+
+ For instance if one of the `vue-autonumeric` component had a `decimalPlaces` option set to `2`, and another set to `5`, then when the user modified the value of one of those components, vue-autonumeric would detect a programmatic value change in the other component (since it did not come from a user interaction), and it would then use `set()` to set the new value.
8+
+ The first component would drop the additional decimal places when using `set()`...which in turn would make the other components aware of that new value change, and the second component would then use that new cropped value as well.
9+
+ However, this special decimal places management is complexifying the code quite a bit, and is not 100% effective since some use cases were difficult, if even possible, to manage.
10+
+ This `rawValueDecimalPlaces` *hack* is now reverted to a more sane and legible code.
11+
+ From now on, the user will have to explicitly declare the `rawValueDecimalPlaces` value when updating the options, if he does not want to lose the precision when switching options.
12+
+ Fix the case of the AutoNumeric import name in the webpack configuration
13+
314
### 1.1.0
415
+ Fix issue #10 When using an object to modify both the `:value` and `:options` props, the options is not always modified before the value
516
+ Fix the issue where updating the `options` to new ones with a higher `decimalPlacesRawValue` loses the additional decimal places
617
+ Now allows to update the `options` by passing an array of options (with objects and predefined option names)
718
+ When the `options` and `value` are both set at the same time, `vue-autonumeric` now always update the `options` first, before setting the `value`.
819
+ This allows to use objects with the value and a predefined option name to modify the vue-autonumeric component.
9-
+ Note: There is a know bug yet; if you use multiple `vue-autonumeric` component sharing the same `v-model` but *different* options, changing the value/option *may* not work correctly.
20+
+ Note: There is a known bug; if you use multiple `vue-autonumeric` component sharing the same `v-model` but *different* options, changing the value/option *may* not work correctly.
1021
+ This is due to the fact that when vue-autonumeric detects a value change, it `set()` it since it does not come from a user interaction.
1122
+ However if one of the `vue-autonumeric` component has a `decimalPlaces` option set to `2`, and another set to `5`, then the first component will drop the additional decimal places when using `set()`...which in turn will make the other component aware of that new value change, and the second component will then use that new cropped value as well.
1223

build/webpack.base.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ module.exports = {
6969
},
7070

7171
externals: {
72-
// This prevent bundling the AutoNumeric library inside the vue-autornumeric component
72+
// This prevent bundling the AutoNumeric library inside the vue-autonumeric component
7373
// cf. https://webpack.js.org/configuration/externals/
74-
AutoNumeric: 'AutoNumeric',
74+
autonumeric: 'AutoNumeric',
7575
},
7676
};

0 commit comments

Comments
 (0)