#2781·taipy

[ BUG] Variable values desynchronisation

Author: arcanaxionCreated Dec 10, 2025Updated Aug 6, 2026
Labels🖰 GUI🟨 Priority: Medium

What went wrong?

In the following examples, click on >3-5 table rows and/or selector options and you should see some unexpected behaviour.

1. Linking a selector component to a table component

When the user interacts with one component, the other component should also be updated. I have seen this requirement also involve linking markers on a chart with records on a table.

Code
python
import pandas as pd
import taipy.gui.builder as tgb
from taipy.gui import Gui, notify

feature_list = [f"Feature {i:<4}" for i in range(1000)]
selected_features = feature_list[:50]


def create_feature_table(state):
    feature_selection_df = pd.DataFrame(
        {
            "Feature": feature_list,
            "Type": ["Numerical" if i % 3 else "Categorical" for i in range(1000)],
            "Selected": [True if feature in state.selected_features else False for feature in feature_list],
        }
    )
    return feature_selection_df

feature_selection_df = None

def table_click_feature(state, var_name, payload):
    index = payload["index"]
    feature_name = state.feature_selection_df.loc[index, "Feature"]
    if state.feature_selection_df.loc[index, "Selected"]:
        notify(state, "I", f"Feature '{feature_name}' deselected")
        state.selected_features.remove(feature_name)
    else:
        notify(state, "I", f"Feature '{feature_name}' selected")
        state.selected_features.append(feature_name)
    state.refresh("selected_features")
    state.feature_selection_df = create_feature_table(state)

def on_init(state):
    state.feature_selection_df = create_feature_table(state)

with tgb.Page() as page:
    tgb.toggle(theme=True)
    with tgb.part(class_name="container"):
        with tgb.part(class_name="card mb1"):
            tgb.text("# Feature Selector", mode="md")
            with tgb.layout(columns="340px 1"):
                tgb.selector(
                    "{selected_features}",
                    lov="{feature_list}",
                    multiple=True,
                    height="340px",
                    filter=True,
                    label="Select Features",
                    show_select_all=True,
                    on_change=lambda state: state.assign("feature_selection_df", create_feature_table(state)),
                )
                tgb.text(lambda selected_features: f"**Feature columns:** {', '.join(selected_features)}", mode="md")

        # Example of using a table as a paginated filterable selector
        tgb.table("{feature_selection_df}", rebuild=True, filter=True, on_action=table_click_feature, use_checkbox=True)

Gui(page=page).run(title="Feature column selector", run_browser=False, server_config={"socketio": {"ping_interval": 1}})

2. Just table

Code
python
import taipy.gui.builder as tgb
from taipy.gui import Gui, State, notify

feature_list = [f"Feature {i:04}" for i in range(1000)]
selected_features = feature_list[:50]

def create_feature_table(state: State):
    feature_selection_dict = {
        "Feature": feature_list,
        "Type": ["Numerical" if i % 3 else "Categorical" for i in range(1000)],
        "Selected": [True if feature in state.selected_features else False for feature in feature_list],
    }

    return feature_selection_dict

feature_selection_dict = None

def table_click_feature(state: State, var_name: str, payload):
    index = payload["index"]
    feature_name = state.feature_selection_dict["Feature"][index]
    if state.feature_selection_dict["Selected"][index]:
        notify(state, "I", f"Feature '{feature_name}' deselected")
        state.selected_features.remove(feature_name)
    else:
        notify(state, "I", f"Feature '{feature_name}' selected")
        state.selected_features.append(feature_name)
    state.refresh("selected_features")
    state.feature_selection_dict = create_feature_table(state)

def on_init(state):
    state.feature_selection_dict = create_feature_table(state)

with tgb.Page() as page:
    tgb.toggle(theme=True)
    with tgb.part(class_name="container"):
        with tgb.part(class_name="card mb1"):
            tgb.text("# Feature Selector", mode="md")
            with tgb.layout(columns="340px 1"):
                tgb.text(lambda selected_features: f"**Feature columns:** {', '.join(selected_features)}", mode="md")

        # Example of using a table as a paginated filterable selector
        tgb.table("{feature_selection_dict}", rebuild=True, filter=True, on_action=table_click_feature)

Gui(page=page).run(title="Feature column selector", run_browser=False)

3. Table with patching

Code

Same code as example 2, but replace the following function with:

python
def table_click_feature(state: State, var_name: str, payload):
    index = payload["index"]
    feature_name = state.feature_selection_dict["Feature"][index]
    if state.feature_selection_dict["Selected"][index]:
        notify(state, "I", f"Feature '{feature_name}' deselected")
        idx_to_remove = state.selected_features.index(feature_name)
        state.patch("selected_features", remove={idx_to_remove: None})
        state.patch("feature_selection_dict", change={"Selected": {index: False}})
    else:
        notify(state, "I", f"Feature '{feature_name}' selected")
        state.patch("selected_features", change={len(state.selected_features): feature_name})
        state.patch("feature_selection_dict", change={"Selected": {index: True}})
    state.refresh("selected_features")
    state.refresh("feature_selection_dict")

Taipy Version

develop

Additional Context (Optional)

bash

Code of Conduct

  • I have checked the existing issues to avoid duplicates.
  • I am willing to work on this issue (optional)

✅ Acceptance Criteria

  • A reproducible unit test is added.
  • Code coverage is at least 90%.
  • The bug reporter validated the fix.
  • Relevant documentation updates or an issue created in