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

Linking Two Inputs: format function change does not trigger a rerender #8405

Closed
smeng9 opened this issue Nov 18, 2022 · 2 comments · Fixed by #8422 or #8453
Closed

Linking Two Inputs: format function change does not trigger a rerender #8405

smeng9 opened this issue Nov 18, 2022 · 2 comments · Fixed by #8422 or #8453
Labels

Comments

@smeng9
Copy link
Contributor

smeng9 commented Nov 18, 2022

I have two inputs in a form: one for the value and another for the unit

What you were expecting:

I expect changing the unit from selection input will cause the value also be reformatted based on the new unit

What happened instead:

The value does not get reformatted

Steps to reproduce:

Go to https://stackblitz.com/edit/github-m7rhmv?file=src%2Fcomments%2FCommentCreate.tsx
Go to Comments -> Create new comments
In the form change the units to degrees or radians, however in the value input only input adornment gets changed, but not the input value.

Related code:

The value may need to be recalculated here

value: format ? format(controllerField.value) : controllerField.value,

Maybe missing a dependency in useEffect

}, [field.value]); // eslint-disable-line react-hooks/exhaustive-deps

https://stackblitz.com/edit/github-m7rhmv?file=src%2Fcomments%2FCommentCreate.tsx

Other information:

Environment

  • React-admin version: 4.5.1
  • Last version that did not exhibit the issue (if applicable): N/A
  • React version: 18.0.2
  • Browser: Firefox 106
  • Stack trace (in case of a JS error):
@WiXSL WiXSL added the bug label Nov 21, 2022
@WiXSL
Copy link
Contributor

WiXSL commented Nov 21, 2022

Reproduced!
Thanks.

It works with a TextInput, you can use that for now as a workaround

@fzaninotto
Copy link
Member

The fix was reverted in #8442, so I'm reopening this bug.

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