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

Event recursion on input in tui #57

Open
1 of 3 tasks
gh22749268 opened this issue Jan 6, 2024 · 0 comments
Open
1 of 3 tasks

Event recursion on input in tui #57

gh22749268 opened this issue Jan 6, 2024 · 0 comments
Labels
bug Something isn't working tui Related to dioxus TUI

Comments

@gh22749268
Copy link

Problem

The oninput event fall into recursion when the listener changes its own property.
Additionally, before emitting the event, it should be checked if the value is not equal to the previous one. This prevents recursion on slower input, but the issue still appears with faster inputs.

Steps To Reproduce

Steps to reproduce the behavior:

[dependencies]
dioxus = "0.4.3"
dioxus-tui = "0.4.3"
#![allow(non_snake_case)]
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
use dioxus::prelude::*;

fn main() {
    // launch the app in the terminal
    dioxus_tui::launch(App);
}

// create a component that renders a div with the text "Hello, world!"
pub fn App(cx: Scope) -> Element {
    let name = use_state(cx, || "bob".to_string());

    cx.render(rsx! {
        input {
            // we tell the component what to render
            value: "{name}",
            // and what to do when the value changes
            oninput: move |evt| name.set(evt.value.clone()),
        }
    })
}

Expected behavior

Should not

Screenshots

If applicable, add screenshots to help explain your problem.

Environment:

  • Dioxus version: 0.4.3
  • Rust version: 1.70.0
  • OS info: any
  • App platform: tui

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@ealmloff ealmloff added the bug Something isn't working label Jan 9, 2024
@jkelleyrtp jkelleyrtp transferred this issue from DioxusLabs/dioxus Mar 18, 2024
@ealmloff ealmloff added the tui Related to dioxus TUI label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tui Related to dioxus TUI
Projects
None yet
Development

No branches or pull requests

2 participants