Skip to content

Commit 4e671aa

Browse files
committed
🐛 fix #1098 : also persist 0, empty string etc
fixes #1098 Persistence does not work for Input components when 0 is entered
1 parent 38994eb commit 4e671aa

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
All notable changes to `dash` will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## Next
6+
- [#1142](https://github.com/plotly/dash/pull/1142) [Persistence](https://dash.plot.ly/persistence): Also persist 0, empty string etc
7+
58
## [1.9.1] - 2020-02-27
69
### Added
710
- [#1133](github.com/plotly/dash/pull/1133) Allow the `compress` config variable to be set with an environment variable with DASH_COMPRESS=FALSE

dash-renderer/src/persistence.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export function recordUiEdit(layout, newProps, dispatch) {
319319

320320
forEach(persistedProp => {
321321
const [propName, propPart] = persistedProp.split('.');
322-
if (newProps[propName]) {
322+
if (newProps[propName] !== undefined) {
323323
const storage = getStore(persistence_type, dispatch);
324324
const {extract} = getTransform(element, propName, propPart);
325325

tests/integration/renderer/test_persistence.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ def set_out(val):
401401

402402
dash_duo.find_element('#persistence-val').send_keys('2')
403403
dash_duo.wait_for_text_to_equal('#out', 'a')
404-
dash_duo.find_element('#persisted').send_keys('ardvark')
405-
dash_duo.wait_for_text_to_equal('#out', 'aardvark')
404+
dash_duo.find_element('#persisted').send_keys('') # persist falsy value
405+
dash_duo.wait_for_text_to_equal('#out', '')
406406

407407
# alpaca not saved with falsy persistence
408408
dash_duo.clear_input('#persistence-val')
@@ -412,7 +412,7 @@ def set_out(val):
412412
dash_duo.find_element('#persistence-val').send_keys('s')
413413
dash_duo.wait_for_text_to_equal('#out', 'anchovies')
414414
dash_duo.find_element('#persistence-val').send_keys('2')
415-
dash_duo.wait_for_text_to_equal('#out', 'aardvark')
415+
dash_duo.wait_for_text_to_equal('#out', '')
416416

417417

418418
def test_rdps011_toggle_persistence2(dash_duo):

0 commit comments

Comments
 (0)