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

Defective behavior of date-picker when deleting #39

Closed
egg-juxt opened this issue Oct 11, 2022 · 2 comments
Closed

Defective behavior of date-picker when deleting #39

egg-juxt opened this issue Oct 11, 2022 · 2 comments

Comments

@egg-juxt
Copy link

egg-juxt commented Oct 11, 2022

I am experiencing some unexpected cursor jumps when deleting a date-picker using the backspace key. This happens when date-picker is created with the property:

                 :render-input (react-component [props]
                                 [text-field props])

as in this example.

The cursor behaves correctly with the property:

       :renderInput (fn [params]
                      (r/as-element
                        [mui/text-field (js->clj params)]))

Why is this?

@arttuka
Copy link
Owner

arttuka commented Feb 11, 2023

Looks like DatePicker is setting the cursor position when you type in the text field. If it is a Reagent input, Reagent also tries to set the cursor position which causes the cursor to jump unexpectedly.

The solution is to render a React input instead of a Reagent input:

(:require [react :as react]
          ["@mui/material/TextField" :as MuiTextField])

:render-input (fn [params] (react/createElement MuiTextField/default params))

Using js->clj fixed the issue by accident. It caused invalid props to be passed to mui/text-field so a default input was rendered instead of the custom Reagent input.

@arttuka arttuka closed this as completed Feb 11, 2023
@egg-juxt
Copy link
Author

Thanks, appreciate your help on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants