holoviz / panel

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

Cell Focus Resets on TAB Press in Tabulator When Styles Are Active #7465

Open krishanunayak opened 2 weeks ago

krishanunayak commented 2 weeks ago
Software Version Info ```plaintext panel==1.5.0 ```

Description of expected behavior and the observed behavior

Expected Behavior: After applying styles to a Tabulator using the pandas styling API, editing a cell and pressing TAB should retain cell focus and maintain the current view.

Observed Behavior: When a style is applied, pressing TAB after editing a cell causes the Tabulator to lose focus and resets the view.

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

import panel as pn
import pandas as pd
from panel.viewable import Viewable

pn.extension("tabulator")

def apply_style(col):
    return [
        ("outline: 1px solid rgba(255, 0, 0, 0.5);" if (col.name % 2) else "")
        for _ in col
    ]

class App(pn.viewable.Viewer):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        df = pd.DataFrame({i: list(range(5)) for i in range(10)})
        self.table = pn.widgets.Tabulator(value=df)
        self.table.style.apply(apply_style)

    def __panel__(self) -> Viewable:
        return self.table

App().servable()

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

https://github.com/user-attachments/assets/e3a83a0a-9a77-47ad-9191-9664d29e346e