Closed katyo closed 11 months ago
I fixed it in #349. It works fine but I'm not sure that my solution is fully correct.
Hey! Your fix makes sense but I can't seem to reproduce the error without your fix. What exactly did you do to trigger it?
My simplified example to reproduce error:
let text = use_state(cx, || "".to_string());
Input {
value: text.get().clone(),
onchange: |event: String| text.set(event.trim().to_string()),
}
In empty input press space next insert some non-space char and either press space again or backspace.
Your fix indeed seems to fix it! Although now I see another issue, when you press space, it will move the cursor even though the text
doesn't contain a space, I'll see what I can do about that
Looks like we need a way to precise control input which includes updating cursor position (and maybe text selection) simultaneously with updating contents.
Looks like we need a way to precise control input which includes updating cursor position (and maybe text selection) simultaneously with updating contents.
No worries! I just pushed a fix in your PR, I think it works great, let me know what you think!
@marc2332 I tested your changes. Now it works as expected. Thank you so much! Have you future plans to add ability to control text cursor and selection?
Also I found some wrong behavior related to text selection. I will create new issue for that.
Have you future plans to add ability to control text cursor and selection?
Of course! Many things can still be improved
I remove some characters while user input so the length of edited text is reduced but cursor position stay some as before:
I think we need sync cursor position with actual text string length before inserting or removing characters while editing to prevent such wrong behavior. Currently I'm not quite familiar with dioxus/freya architecture so I don't sure where the right place to do it.