Skip to content

Commit

Permalink
Ensure parameter overrides are applied to ESM components (#7452)
Browse files Browse the repository at this point in the history
* Ensure parameter overrides are applied to ESM components

* Small fix
  • Loading branch information
philippjfr authored Oct 31, 2024
1 parent f712587 commit b43a52a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion panel/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,14 @@ def _get_properties(self, doc: Document) -> dict[str, Any]:
props = super()._get_properties(doc)
cls = type(self)
data_params = {}
ignored = [p for p in Reactive.param if not issubclass(cls.param[p].owner, ReactiveESM)]
# Split data model properties from ESM model properties
# Note that inherited parameters are generally treated
# as ESM model properties unless their type has changed
ignored = [
p for p in Reactive.param
if not issubclass(cls.param[p].owner, ReactiveESM) or
(p in Viewable.param and p != 'name' and type(Reactive.param[p]) is type(cls.param[p]))
]
for k, v in self.param.values().items():
p = self.param[k]
is_viewable = is_viewable_param(p)
Expand Down
15 changes: 15 additions & 0 deletions panel/tests/test_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,18 @@ def test_reactive_esm_children_models_cleanup_on_replace(document, comm):
assert ref in md2._models
md2_model, _ = md2._models[ref]
assert model.data.children == [md2_model]

class ESMOverride(ReactiveESM):

width = param.Integer(default=42)

def test_esm_parameter_override(document, comm):
esm = ESMOverride()

model = esm.get_root(document, comm)

assert model.width == 42

esm.width = 84

assert model.width == 84

0 comments on commit b43a52a

Please sign in to comment.