ripe-tech / ripe-sdk

The public Javascript SDK for RIPE Core
https://www.platforme.com
Apache License 2.0
8 stars 4 forks source link

#641 Fix setting initialsExtra in root and options of ripe instance #249

Closed 3rdvision closed 3 years ago

3rdvision commented 3 years ago
- -
Issue https://github.com/ripe-tech/ripe-white/issues/641#issuecomment-780589887
Decisions This bug was introduced at a refactor after the fix. This regression exposes an unexpected RIPE SDK behavior - when we do setInitialsExtra it sets ripe.initialsExtra but not ripe.options.initialsExtra.

On the other hand config() sets both ripe.initialsExtra and ripe.options.initialsExtra, that's why it was working before the refactor when we were doing everything in config().

Now RIPE White uses $ripe.initials, $ripe.engraving and $ripe.initialsExtra for the originalState and $ripe.options.initials, $ripe.options.engraving and $ripe.options.initialsExtra for the state. When we reproduce the bug by changing to a different model it will reset the originalState correctly but not the state (ripe.options.initialsExtra is still dirty with old model's personalization). This buttonText showing the old personalization happens only for a short amount of time depending on how fast the JS code runs because it later receives an event with empty personalization which overrides it but the old state always remains there.

This fix sets both ripe.initialsExtra and ripe.options.initialsExtra when doing setInitialsExtra

Note: setSize already writes to both this.size and this.options.size so we might want the same effect for setInitials and setInitialsExtra.
Animated GIF Peek 2021-02-18 17-09
joamag commented 3 years ago

We need to be careful to avoid breaking changes at a core level, I've made updating options optional (using override flag) this is in line with other methods in Ripe and should fix the behaviour.