holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.82k stars 521 forks source link

List header filter fails to find matching rows in 1.5.0 #7326

Open bbercoviciUspace opened 2 months ago

bbercoviciUspace commented 2 months ago

ALL software version info

Description of expected behavior and the observed behavior

The list header filters are no longer working. Instead of extracting the relevant rows, filling the filter empties the panel and triggers a warning in the browser console. This issue manifested itself after upgrading from 1.4.5 to 1.5.0.

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

Column header filters defined as list filters, such as the following applied to the processName column

"processName": {
                "type": "list",
                "valuesLookup": True,
}

are not working properly in 1.5.0.

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

1.4.5 : the filter extracts the expected rows Screenshot from 2024-09-26 16-45-50

No warning is shown in the inspect window

1.5.0 : the filter clears the entire table although there are rows matching the pattern in the dataset. Screenshot from 2024-09-26 16-46-12

The inspect window shows the following warning :

image

Coderambling commented 1 month ago

Could you add your code to the issue so there is an MRE that can be tested easily?

bbercoviciUspace commented 1 month ago

I think I found a fix while trying to come up with a minimum example:

import panel as pn
import pandas as pd
import string

filters = {
            "field_A": {
                "type": "list",
                "valuesLookup": True,
                "placeholder" : "list"
            },
            "field_B": {
                "type": "input",
                "placeholder" : "input"

            }
            }

data = list()
for i in range(100):
    data.append(dict(field_A = string.ascii_lowercase[i % len(string.ascii_lowercase)], field_B = string.ascii_lowercase[(i + 3) % len(string.ascii_lowercase)]))

dataframe = pd.DataFrame(data)
panel_args = dict(value = dataframe,layout="fit_data_table", header_filters=filters)
tabulator = pn.widgets.Tabulator(**panel_args)
tabulator.save("test_panel.html")

The above script produced the attached test_panel_buggy.html file

Screenshot from 2024-10-01 13-51-00

test_panel_buggy.zip

For reasons beyond my understanding, adding the func : "like" to the list typed header filters brings back the search results

import panel as pn
import pandas as pd
import string

filters = {
            "field_A": {
                "type": "list",
                "func": "like",
                "valuesLookup": True,
                "placeholder" : "list"
            },
            "field_B": {
                "type": "input",
                "placeholder" : "input"

            }
            }

data = list()
for i in range(100):
    data.append(dict(field_A = string.ascii_lowercase[i % len(string.ascii_lowercase)], field_B = string.ascii_lowercase[(i + 3) % len(string.ascii_lowercase)]))
dataframe = pd.DataFrame(data)
panel_args = dict(value = dataframe,layout="fit_data_table",header_filters=filters)
tabulator = pn.widgets.Tabulator(**panel_args)
tabulator.save("test_panel.html")

Screenshot from 2024-10-01 13-52-57 test_panel_fixed.zip

I'm positive that this fix became necessary sometime around when panel 1.5.0 rolled out.

Coderambling commented 1 month ago

Good find!