panel
panel copied to clipboard
Tabulator in FloatPanel height size is not correct (MRE) when the floatpanel is dynamically added
If you have a Tabulator in a FloatPanel it sizes correctly if it is loaded into the page directly (and contained is the default True); but if you load it dynamically into a Row with contained as either True or False then it does not size the height correctly of the FloatPanel. It is true if you use other widgets also (i.e. TextInput, FloatSlider), just not as obvious.
Was first brought up here: (https://discourse.holoviz.org/t/tabulator-in-floatpanel-height-size-is-not-correct-mre-when-the-floatpanel-is-dynamically-added/6497/1)
Panel v1.3.6
import panel as pn
import pandas as pd
# Define your Panel layout here
layout = pn.Column('# Hello, World!')
pn.extension('tabulator')
pn.extension('floatpanel')
floating_panels_column = pn.Row(background='red')
df = pd.DataFrame({
'int': [1, 2, 3,4, 5, 6],
'float': [3.14, 6.28, 9.42, 10.56, 12.70, 15.84],
'str': ['A', 'B', 'C', 'D', 'E', 'F'],
'bool': [True, False, True, False, True, False]
}, index=[1, 2, 3, 4, 5, 6])
df_widget = pn.widgets.Tabulator(df, buttons={'Print': "<i class='fa fa-print'></i>"})
def process_click(event):
print('process_click')
floatpanel = pn.layout.FloatPanel(w1, df_widget, w2, name='Basic FloatPanel', margin=20)
floatpanel.param.watch(floatpanel_close_callback, 'status')
floating_panels_column.append(floatpanel)
def floatpanel_close_callback(event):
print('in callback')
print(event)
if event.obj.status == 'closed':
print('closed')
floating_panels_column.remove(event.obj)
w1 = pn.widgets.TextInput(name='Text:')
w2 = pn.widgets.FloatSlider(name='Slider')
floatpanel = pn.layout.FloatPanel(w1, df_widget, w2, name='Basic FloatPanel', margin=20)
floatpanel.param.watch(floatpanel_close_callback, 'status')
floating_panels_column.append(floatpanel)
floatpanel = pn.layout.FloatPanel(w1, df_widget, w2, name='Basic FloatPanel', margin=20, contained=False)
floatpanel.param.watch(floatpanel_close_callback, 'status')
floating_panels_column.append(floatpanel)
button = pn.widgets.Button(name='Click me')
button.on_click(process_click)
layout.append(button)
layout.append(floating_panels_column)
layout.append(pn.Column("This is a basic Panel layout."))
layout.servable()
I dug a bit deeper. Debugging through jspanel.js it may be contentSize is "null null" but I saw that all jsPanel.create calls were null null. I am afraid it may be a timing issue related to the content nodes (the child elements) being added to the DOM with jspanel, but I'm not certain.
- [X] I may be interested in making a pull request to address this.