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

Fixes for layout caching and sizing #6446

Merged
merged 3 commits into from
Mar 6, 2024
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
3 changes: 2 additions & 1 deletion panel/layout/accordion.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Accordion(NamedListPanel):

def __init__(self, *objects, **params):
super().__init__(*objects, **params)
self._panels = {}
self._updating_active = False
self.param.watch(self._update_active, ['active'])
self.param.watch(self._update_cards, self._synced_properties)
Expand All @@ -104,7 +105,7 @@ def _get_objects(self, model, old_objects, doc, root, comm=None):
self.objects[i] = pane

for obj in old_objects:
if obj not in self.objects:
if obj not in self.objects and id(obj) in self._panels:
self._panels[id(obj)]._cleanup(root)
del self._panels[id(obj)]

Expand Down
6 changes: 3 additions & 3 deletions panel/layout/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def _get_objects(
current_objects = list(self.objects)
ref = root.ref['id']
for i, pane in enumerate(self.objects):
if pane in old_objects and ref in pane._models:
if ref in pane._models:
child, _ = pane._models[root.ref['id']]
old_models.append(child)
else:
Expand Down Expand Up @@ -293,15 +293,15 @@ def _compute_sizing_mode(self, children, props):
properties = {'sizing_mode': sizing_mode}
if (sizing_mode.endswith(("_width", "_both")) and
widths and 'min_width' not in properties):
width_op = max if self._direction == 'vertical' else sum
width_op = max if self._direction in ('vertical', None) else sum
min_width = width_op(widths)
op_widths = [min_width]
if 'max_width' in properties:
op_widths.append(properties['max_width'])
properties['min_width'] = min(op_widths)
if (sizing_mode.endswith(("_height", "_both")) and
heights and 'min_height' not in properties):
height_op = max if self._direction == 'horizontal' else sum
height_op = max if self._direction in ('horizontal', None) else sum
min_height = height_op(heights)
op_heights = [min_height]
if 'max_height' in properties:
Expand Down
2 changes: 1 addition & 1 deletion panel/layout/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _get_objects(
ref = root.ref['id']
for i in range(*self._last_synced):
pane = current_objects[i]
if pane in old_objects and ref in pane._models:
if ref in pane._models:
child, _ = pane._models[root.ref['id']]
old_models.append(child)
else:
Expand Down
2 changes: 1 addition & 1 deletion panel/layout/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Tabs(NamedListPanel):

_bokeh_model: ClassVar[Type[Model]] = BkTabs

_direction: ClassVar[str | None] = 'vertical'
_direction: ClassVar[str | None] = None

_js_transforms: ClassVar[Mapping[str, str]] = {'tabs': """
var ids = [];
Expand Down
Loading