Skip to content

json_editor in Tabbed Interface Problems #5333

@natankeddem

Description

@natankeddem

First Check

  • I added a very descriptive title here.
  • This is not a Q&A. I am sure something is wrong with NiceGUI or its documentation.
  • I used the GitHub search to find a similar issue and came up empty.

Example Code

from nicegui import ui

with ui.tabs().classes("w-full") as tabs:
    one = ui.tab("One")
    two = ui.tab("Two")
with ui.tab_panels(tabs, value=one).classes("w-full"):
    with ui.tab_panel(one):
        e_one = ui.json_editor({"content": {"json": {"price": 15.0}}})
    with ui.tab_panel(two):
        e_two = ui.json_editor({"content": {"json": {"price": 15.0}}})


def change_tab_two():
    e_two.properties["content"]["json"]["price"] = e_two.properties["content"]["json"]["price"] + 1


ui.button("Change Data in Tab Two", on_click=change_tab_two)

ui.run()

Description

I am refactoring code from v2 to v3 and found some strange behaviour when using multiple json_editor elements inside separate tabbed interfaces. Firstly if you attempt to manipulate data in an editor that hasn't been rendered yet (tab hasn't been selected and element viewed) you get a console warning. This doesn't happen on v2. This can be simulated by pressing the "Change Data in Tab Two" button immediately on page load in the example. Also, when switching between tabs the UI seems to lock up until page refresh:

ngtab0.webm

NiceGUI Version

3.1.0

Python Version

Python 3.13.1

Browser

Chrome

Operating System

Windows

Additional Context

It seems like some of this could be browser specific. For example the tab switching issue I can't get to happen in Firefox but happens readily in Chrome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    analysisStatus: Requires team/community inputbugType/scope: A problem that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions