Skip to content

Commit fc4dad2

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

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-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

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import pytest
33
import time
44

5+
from selenium.webdriver.common.keys import Keys
6+
57
import dash
68
from dash.dependencies import Input, Output
79

@@ -401,8 +403,8 @@ def set_out(val):
401403

402404
dash_duo.find_element('#persistence-val').send_keys('2')
403405
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')
406+
dash_duo.find_element('#persisted').send_keys(Keys.BACK_SPACE) # persist falsy value
407+
dash_duo.wait_for_text_to_equal('#out', '')
406408

407409
# alpaca not saved with falsy persistence
408410
dash_duo.clear_input('#persistence-val')
@@ -412,7 +414,7 @@ def set_out(val):
412414
dash_duo.find_element('#persistence-val').send_keys('s')
413415
dash_duo.wait_for_text_to_equal('#out', 'anchovies')
414416
dash_duo.find_element('#persistence-val').send_keys('2')
415-
dash_duo.wait_for_text_to_equal('#out', 'aardvark')
417+
dash_duo.wait_for_text_to_equal('#out', '')
416418

417419

418420
def test_rdps011_toggle_persistence2(dash_duo):

0 commit comments

Comments
 (0)