Skip to content

BUG - Updating Modal via modal.objects results in the display of the updated objects in place of modal #7669

Description

@SultanOrazbayev

ALL software version info

(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc should be added within the dropdown below.)

Software Version Info
panel==1.6.0

Description of expected behavior and the observed behavior

Running the code below will show the modal window as expected. However, if the lines inside __update_modal are uncommented, then clicking the button inserts the modal contents into the main page and does not show the modal correctly. This bug prevents dynamic update of the modal contents.

Complete, minimal, self-contained example code that reproduces the issue

import param
from panel import Column, Modal, extension, template, widgets

extension("modal")


class TestApp(param.Parameterized):
    text = param.String(default="Hello, World!")
    slider = param.Number(default=0.0)

    def __init__(self, **params):
        super().__init__(**params)
        self.modal = Modal("TEST", widgets.TextInput(name="Text:", value=self.text), name="Basic FloatPanel", margin=20)
        self.toggle_button = widgets.Button(name="Toggle modal", button_type="primary")
        self.toggle_button.on_click(lambda event: self.__update_modal())

    def __update_modal(self):
        # self.modal.objects = [
        #     widgets.FloatSlider(name="Slider", value=self.slider),
        # ]
        self.modal.show()

    def __panel__(self):
        return Column(
            self.modal,
            self.toggle_button,
        )


test = TestApp()
app = template.VanillaTemplate(title="Basic Modal", main=[test])
app.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions