Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log sometime repeats text #1173

Closed
BrianLandry opened this issue Jul 15, 2023 · 2 comments
Closed

Log sometime repeats text #1173

BrianLandry opened this issue Jul 15, 2023 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@BrianLandry
Copy link
Contributor

Description

I am experiencing a weird duplicated output from a log element created within a function.

Example:

from nicegui import ui

log_works = ui.log().classes("h-64 w-full")

def test():
    log_works.push("a")
    log_works.push("b")
    log_works.push("c")
    log_repeated = ui.log().classes("h-64 w-full")
    log_repeated.push("a")
    log_repeated.push("b")
    log_repeated.push("c")


ui.button("test", on_click=test)
ui.run()

log_works output:

a
b
c

log_repeated output:

a
b
c
a
b
c

Weirdly, if only a single push is performed I don't see this behavior:

from nicegui import ui

log_works = ui.log().classes("h-64 w-full")

def test():
    log_works.push("a")
    log_repeated = ui.log().classes("h-64 w-full")
    log_repeated.push("a")


ui.button("test", on_click=test)
ui.run()

log_works output:

a

log_repeated output:

a
@falkoschindler
Copy link
Contributor

Thanks for reporting this issue, @BrianLandry!
The code example should really help to hunt this bug. 🐞

@falkoschindler falkoschindler added the bug Something isn't working label Jul 15, 2023
@falkoschindler
Copy link
Contributor

Commit baf5902 should fix this issue.

By checking for equality of the current total_count and the target total_count, we missed the case where the frontend is already ahead by two or more pushs.

@falkoschindler falkoschindler added this to the 1.3.4 milestone Jul 15, 2023
@falkoschindler falkoschindler self-assigned this Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants