Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master 2.10.1 #2550

Merged
merged 16 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ describe('Test Typescript component metadata generation', () => {
test(
`${componentName} tuple tuple`,
testTypeFactory('a_tuple', 'tuple')
)
);
test(
`${componentName} object of string`,
testTypeFactory('object_of_string', 'objectOf')
);
test(
`${componentName} object of components`,
testTypeFactory('object_of_components', 'objectOf')
);
});

describe('Test prop attributes', () => {
Expand Down Expand Up @@ -252,6 +260,17 @@ describe('Test Typescript component metadata generation', () => {
R.path(tuplePath.concat(1, 'name'), metadata)
).toBe('string');
}
);

test(
'objectOf node', () => {
const objectOfComponents = R.path(
propPath("TypeScriptComponent", "object_of_components")
.concat(["type", "value", "name"]),
metadata
);
expect(objectOfComponents).toBe("node");
}
)
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export type TypescriptComponentProps = {
nested?: Nested;

a_tuple?: [number, string];

object_of_string?: {[k: string]: string};
object_of_components?: {[k: string]: JSX.Element};
};

export type WrappedHTMLProps = {
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [2.10.1] - 2023-05-30

## Fixed

- [#2545](https://github.com/plotly/dash/pull/2545) Fix typescript objectOf generation.
- [#2548](https://github.com/plotly/dash/pull/2548) Fix component as props callback triggering other callbacks not in response, fix [#2487](https://github.com/plotly/dash/issues/2487).

## [2.10.0] - 2023-05-25

## Changed
Expand Down Expand Up @@ -71,6 +78,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#2260](https://github.com/plotly/dash/pull/2260) Experimental support for React 18. The default is still React v16.14.0, but to use React 18 you can either set the environment variable `REACT_VERSION=18.2.0` before running your app, or inside the app call `dash._dash_renderer._set_react_version("18.2.0")`. THIS FEATURE IS EXPERIMENTAL. It has not been tested with component suites outside the Dash core, and we may add or remove available React versions in any future release.
- [#2414](https://github.com/plotly/dash/pull/2414) Add `dash.Patch`for partial update Output props without transferring the previous value in a State.
- [#2414](https://github.com/plotly/dash/pull/2414) Add `allow_duplicate` to `Output` arguments allowing duplicate callbacks to target the same prop.
- [#2349](https://github.com/plotly/dash/pull/2349) Added new `dcc.Geolocation` component

## Fixed

Expand Down Expand Up @@ -143,7 +151,6 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Added

- [#2349](https://github.com/plotly/dash/pull/2349) Added new `dcc.Geolocation` component
- [#2261](https://github.com/plotly/dash/pull/2261) Added new `placeholder_text` property to `filterOptions` for DataTable which allows overriding the default filter field placeholder.

### Updated
Expand Down
4 changes: 2 additions & 2 deletions dash/_dash_renderer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

__version__ = "1.15.2"
__version__ = "1.15.3"

_available_react_versions = {"16.14.0", "18.2.0"}
_available_reactdom_versions = {"16.14.0", "18.2.0"}
Expand Down Expand Up @@ -64,7 +64,7 @@ def _set_react_version(v_react, v_reactdom=None):
{
"relative_package_path": "dash-renderer/build/dash_renderer.min.js",
"dev_package_path": "dash-renderer/build/dash_renderer.dev.js",
"external_url": "https://unpkg.com/[email protected].2"
"external_url": "https://unpkg.com/[email protected].3"
"/build/dash_renderer.min.js",
"namespace": "dash",
},
Expand Down
8 changes: 4 additions & 4 deletions dash/dash-renderer/build/dash_renderer.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash/dash-renderer/build/dash_renderer.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dash/dash-renderer/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 dash/dash-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-renderer",
"version": "1.15.2",
"version": "1.15.3",
"description": "render dash components in react",
"main": "build/dash_renderer.min.js",
"scripts": {
Expand Down
15 changes: 6 additions & 9 deletions dash/dash-renderer/src/actions/dependencies_ts.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import {
all,
any,
assoc,
concat,
difference,
filter,
flatten,
includes,
isEmpty,
keys,
map,
Expand Down Expand Up @@ -312,13 +310,12 @@ export const getLayoutCallbacks = (
rootId = stringifyId(rootId);
// Filter inputs that are not present in the response
callbacks = callbacks.filter(cb =>
any(
(inp: any) =>
!(
stringifyId(inp.id) === rootId &&
!includes(inp.property, options.filterRoot)
),
cb.callback.inputs
cb.callback.inputs.reduce(
(previous: any, input: any) =>
previous ||
(stringifyId(input.id) == rootId &&
options.filterRoot.includes(input.property)),
false
)
);
}
Expand Down
22 changes: 13 additions & 9 deletions dash/extract-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,20 @@ function gatherComponents(sources, components = {}) {
...getUnion(propType, propObj, newParentType),
raw
};
} else if (propType.indexInfos && propType.indexInfos.length) {
const {type} = propType.indexInfos[0];
name = 'objectOf';
value = getPropType(type, propObj, newParentType);
} else {
value = getProps(
checker.getPropertiesOfType(propType),
propObj,
[],
{},
true,
newParentType,
);
}

value = getProps(
checker.getPropertiesOfType(propType),
propObj,
[],
{},
true,
newParentType,
);
}
}

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.10.0"
__version__ = "2.10.1"
2 changes: 2 additions & 0 deletions tests/integration/callbacks/test_prevent_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import pytest
from flaky import flaky

from dash import Dash, Input, Output, MATCH, html
from dash.exceptions import PreventUpdate
Expand Down Expand Up @@ -174,6 +175,7 @@ def d(_):
dash_duo.wait_for_text_to_equal("#a", "Click")


@flaky(max_runs=3)
@pytest.mark.parametrize("flavor", flavors)
def test_cbpi002_pattern_matching(flavor, dash_duo):
# a clone of cbpi001 just throwing it through the pattern-matching machinery
Expand Down
64 changes: 63 additions & 1 deletion tests/integration/renderer/test_component_as_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from dash_test_components import ComponentAsProp

from dash.dcc import Checklist
from dash.dcc import Checklist, Dropdown
from dash.html import Button, Div, Span


Expand Down Expand Up @@ -379,3 +379,65 @@ def opts(n):

dash_duo.find_elements("#b label > input")[0].click()
dash_duo.wait_for_text_to_equal("#counter", "1")


def test_rdcap004_side_effect_same_component(dash_duo):
options = [
{"label": "aa1", "value": "aa1"},
{"label": "aa2", "value": "aa2"},
{"label": "aa3", "value": "aa3"},
{"label": "best value", "value": "bb1"},
{"label": "better value", "value": "bb2"},
{"label": "bye", "value": "bb3"},
]

app = Dash(__name__)

app.layout = Div(
[
Div(
["Single dynamic Dropdown", Dropdown(id="my-dynamic-dropdown")],
style={"width": 200, "marginLeft": 20, "marginTop": 20},
),
Button(
"Reset",
id="button",
n_clicks=0,
),
Div(0, id="counter"),
]
)
app.clientside_callback(
"function(_, prev) {return parseInt(prev) + 1}",
Output("counter", "children"),
Input("my-dynamic-dropdown", "value"),
State("counter", "children"),
prevent_initial_call=True,
)

@app.callback(
Output("my-dynamic-dropdown", "options"),
Input("my-dynamic-dropdown", "search_value"),
)
def update_options(search_value):
if search_value is None:
return options
return [o for o in options if search_value in o["label"]]

@app.callback(
Output("my-dynamic-dropdown", "value"),
Input("button", "n_clicks"),
)
def on_button(n_clicks):
return None

dash_duo.start_server(app)

# Initial callback
dash_duo.wait_for_text_to_equal("#counter", "1")

search = dash_duo.wait_for_element("#my-dynamic-dropdown input")

search.send_keys("a")

dash_duo.wait_for_text_to_equal("#counter", "1")