Skip to content

Commit d0296de

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 0fe856a commit d0296de

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99
### Changed
1010
- [#1145](https://github.com/plotly/dash/pull/1145) Update from React 16.8.6 to 16.13.0
1111

12+
### Fixed
13+
- [#1142](https://github.com/plotly/dash/pull/1142) [Persistence](https://dash.plot.ly/persistence): Also persist 0, empty string etc
14+
1215
## [1.9.1] - 2020-02-27
1316
### Added
1417
- [#1133](github.com/plotly/dash/pull/1133) Allow the `compress` config variable to be set with an environment variable with DASH_COMPRESS=FALSE

Diff for: dash-renderer/src/persistence.js

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

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

Diff for: 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

@@ -384,8 +386,8 @@ def set_out(val):
384386

385387
dash_duo.find_element("#persistence-val").send_keys("2")
386388
dash_duo.wait_for_text_to_equal("#out", "a")
387-
dash_duo.find_element("#persisted").send_keys("ardvark")
388-
dash_duo.wait_for_text_to_equal("#out", "aardvark")
389+
dash_duo.find_element("#persisted").send_keys(Keys.BACK_SPACE) # persist falsy value
390+
dash_duo.wait_for_text_to_equal("#out", "")
389391

390392
# alpaca not saved with falsy persistence
391393
dash_duo.clear_input("#persistence-val")
@@ -395,7 +397,7 @@ def set_out(val):
395397
dash_duo.find_element("#persistence-val").send_keys("s")
396398
dash_duo.wait_for_text_to_equal("#out", "anchovies")
397399
dash_duo.find_element("#persistence-val").send_keys("2")
398-
dash_duo.wait_for_text_to_equal("#out", "aardvark")
400+
dash_duo.wait_for_text_to_equal('#out', "")
399401

400402

401403
def test_rdps011_toggle_persistence2(dash_duo):

0 commit comments

Comments
 (0)