Skip to content

Commit

Permalink
Merge pull request #2507 from plotly/master-2.9.3
Browse files Browse the repository at this point in the history
Master 2.9.3
  • Loading branch information
T4rk1n committed Apr 13, 2023
2 parents f3d4ffe + ede8102 commit 64a1c25
Show file tree
Hide file tree
Showing 22 changed files with 107 additions and 34 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [2.9.3] - 2023-04-13

## Fixed

- [#2489](https://github.com/plotly/dash/pull/2489) Fix location change event handling when `Location` objects are removed from the layout. Event handlers would not be removed and eventually change props of a random DOM element, fix [#1346](https://github.com/plotly/dash/issues/1346)
- [#2498](https://github.com/plotly/dash/pull/2498) Fix error when caching callbacks which return `Patch` objects by making `Patch` objects picklable
- [#2491](https://github.com/plotly/dash/pull/2491) Fix clientside inline function name not found, fix [#2488](https://github.com/plotly/dash/issues/2488)

## [2.9.2] - 2023-03-29

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2022 Plotly, Inc
Copyright (c) 2023 Plotly, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions components/dash-core-components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/dash-core-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-core-components",
"version": "2.9.1",
"version": "2.9.2",
"description": "Core component suite for Dash",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ export default class Location extends Component {
this.updateLocation(this.props);
}

componentWillUnmount() {
window.onpopstate = () => {};
window.removeEventListener(
'_dashprivate_pushstate',
this.onLocationChange
);
}

UNSAFE_componentWillReceiveProps(nextProps) {
this.updateLocation(nextProps);
}
Expand Down
4 changes: 2 additions & 2 deletions components/dash-html-components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/dash-html-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-html-components",
"version": "2.0.10",
"version": "2.0.11",
"description": "Vanilla HTML components for Dash",
"main": "lib/index.js",
"repository": {
Expand Down
2 changes: 0 additions & 2 deletions components/dash-html-components/scripts/data/attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@
"hrefLang": {
"elements": [
"a",
"area",
"link"
],
"description": "Specifies the language of the linked resource."
Expand Down Expand Up @@ -850,7 +849,6 @@
"coords",
"download",
"href",
"hrefLang",
"media",
"referrerPolicy",
"rel",
Expand Down
6 changes: 3 additions & 3 deletions dash/_callback.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import collections
import uuid
import hashlib
from functools import wraps

import flask
Expand Down Expand Up @@ -534,8 +534,8 @@ def register_clientside_callback(
# name, then inject the code.
if isinstance(clientside_function, str):
namespace = "_dashprivate_clientside_funcs"
# Just make sure every function has a different name if not provided.
function_name = uuid.uuid4().hex
# Create a hash from the function, it will be the same always
function_name = hashlib.md5(clientside_function.encode("utf-8")).hexdigest()

inline_scripts.append(
_inline_clientside_template.format(
Expand Down
6 changes: 6 additions & 0 deletions dash/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def __init__(self, location=None, parent=None):
else:
self._operations = []

def __getstate__(self):
return vars(self)

def __setstate__(self, state):
vars(self).update(state)

def __getitem__(self, item):
validate_slice(item)
return Patch(location=self._location + [item], parent=self)
Expand Down
9 changes: 7 additions & 2 deletions dash/dash-renderer/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ module.exports = config => {
],
reporters: ["progress"],
browsers: ["Chrome"],
webpack: require('./webpack.test.config.js')[0]
webpack: require('./webpack.test.config.js')[0],
client: {
mocha: {
timeout: 5000
}
}
});
}
}
2 changes: 1 addition & 1 deletion dash/dcc/dash_core_components.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash/dcc/dash_core_components.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash/dcc/package-info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-core-components",
"version": "2.9.1",
"version": "2.9.2",
"description": "Core component suite for Dash",
"repository": {
"type": "git",
Expand Down
6 changes: 0 additions & 6 deletions dash/html/Area.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ class Area(Component):
- href (string; optional):
The URL of a linked resource.
- hrefLang (string; optional):
Specifies the language of the linked resource.
- key (string; optional):
A unique identifier for the component, used to improve performance
by React.js while rendering components See
Expand Down Expand Up @@ -154,7 +151,6 @@ def __init__(
coords=Component.UNDEFINED,
download=Component.UNDEFINED,
href=Component.UNDEFINED,
hrefLang=Component.UNDEFINED,
media=Component.UNDEFINED,
referrerPolicy=Component.UNDEFINED,
rel=Component.UNDEFINED,
Expand Down Expand Up @@ -193,7 +189,6 @@ def __init__(
"draggable",
"hidden",
"href",
"hrefLang",
"key",
"lang",
"loading_state",
Expand Down Expand Up @@ -228,7 +223,6 @@ def __init__(
"draggable",
"hidden",
"href",
"hrefLang",
"key",
"lang",
"loading_state",
Expand Down
2 changes: 1 addition & 1 deletion dash/html/dash_html_components.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash/html/dash_html_components.min.js.map

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions dash/html/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -996,13 +996,6 @@
"required": false,
"description": "The URL of a linked resource."
},
"hrefLang": {
"type": {
"name": "string"
},
"required": false,
"description": "Specifies the language of the linked resource."
},
"media": {
"type": {
"name": "string"
Expand Down
2 changes: 1 addition & 1 deletion dash/html/package-info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-html-components",
"version": "2.0.10",
"version": "2.0.11",
"description": "Vanilla HTML components for Dash",
"main": "lib/index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion dash/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.9.2"
__version__ = "2.9.3"
50 changes: 50 additions & 0 deletions tests/integration/clientside/test_clientside_restarts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import pytest
from dash import Dash, html, Output, Input


@pytest.mark.skip(reason="Hot-reload & clientside callbacks doesn't work properly")
def test_clrs001_clientside_inline_restarts(dash_duo_mp):
# FIXME find another way to test clientside callbacks restarts
reloads = 0

def create_app():
nonlocal reloads

app = Dash(__name__)

app.layout = html.Div(
[
html.Button("Click", id="click"),
html.Div(id="output"),
html.Div(reloads, id="reload"),
]
)

app.clientside_callback(
"(n_clicks) => `clicked ${n_clicks}`",
Output("output", "children"),
Input("click", "n_clicks"),
prevent_initial_call=True,
)
reloads += 1
return app

hot_reload_settings = dict(
dev_tools_hot_reload=True,
dev_tools_ui=True,
dev_tools_serve_dev_bundles=True,
dev_tools_hot_reload_interval=0.1,
dev_tools_hot_reload_max_retry=100,
)

dash_duo_mp.start_server(create_app(), **hot_reload_settings)
dash_duo_mp.find_element("#click").click()
dash_duo_mp.wait_for_text_to_equal("#output", "clicked 1")

dash_duo_mp.server.stop()

dash_duo_mp.start_server(create_app(), navigate=False, **hot_reload_settings)
dash_duo_mp.wait_for_text_to_equal("#reload", "1")
dash_duo_mp.find_element("#click").click()
# reloaded so 1 again.
dash_duo_mp.wait_for_text_to_equal("#output", "clicked 1")
11 changes: 11 additions & 0 deletions tests/unit/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,14 @@ def test_pat019_patch_remove():
"location": [],
"params": {"value": "item"},
}


def test_pat020_patch_pickle():
import pickle

p = Patch()
p["a"] = "a"
data = pickle.dumps(p)
q = pickle.loads(data)

assert patch_to_dict(p) == patch_to_dict(q)

0 comments on commit 64a1c25

Please sign in to comment.