Fix <AutocompleteInput> can flicker when used in a <FormDataConsumer>#10496
Fix <AutocompleteInput> can flicker when used in a <FormDataConsumer>#10496
<AutocompleteInput> can flicker when used in a <FormDataConsumer>#10496Conversation
| export const StackedFilters = () => ( | ||
| <AdminContext dataProvider={dataProvider}> | ||
| <ResourceContextProvider value="users"> | ||
| <ListBase> | ||
| <Paper sx={{ p: 2 }}> | ||
| <StackedFiltersForm /> | ||
| <FiltersDebugger /> | ||
| </Paper> | ||
| </ListBase> | ||
| </ResourceContextProvider> | ||
| </AdminContext> | ||
| ); |
There was a problem hiding this comment.
In the end I did not use this story, as we did not change the FormDataConsumer implementation. But I figured we could still keep it to ease tests later. Wdyt, should we keep it?
|
Some tests are failing 🙁 . Back to WIP. |
|
It turns out memoizing the Additionally, we wanted to document the fact that, for now, it's up to the user to make sure to pass a stable reference to the So, for these reasons, I'm closing this PR. |
Problem
Fixes #10415
Supersedes #10417 (which was reverted in 3f6a312 as it caused other issues notably with StackedFilters).
Solution
The flicker actually comes from a missing memoization of the
optionTextprop in the<AutocompleteInput>component.How To Test
For both: Enter a title then select a user. Notice the flicker each time you change the user value. You might have to set a CPU throttle in your devtool to notice it.
FTR: Also added a story allowing to reproduce the issue the first fix attempt created in the
StackedFilterscomponent.To reproduce the bug:
Cannot read properties of null (reading 'focus')Additional Checks
masterfor a bugfix, ornextfor a featureAlso, please make sure to read the contributing guidelines.