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

[fields] Clean the useField hook (part 1) #16944

Merged
merged 14 commits into from
Mar 19, 2025

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Mar 13, 2025

This is the 1st part of the cleaning needed in order to create the new Base UI Field component.

Based on #14679 and #16060
No behavior change

In this PR

  • Move all the logic outside of useField (that will simplify dropping the old DOM structure AND this is needed if we want to build a Base UI version)
  • Pass the manager directly to the useField hook
  • Rationalize the arguments received by the sub-hooks inside useField folder (manager, internalPropsWithDefaults, forwardedProps, stateResponse and characterEditingResponse). This make the data flow a lot easier to reason about for the upcoming changes.
  • Use useTimeout for all the timeout
  • Reduce the amount of intermediate types in useField.types

Follow up

  • Split the logic inside useFieldV7TextField into smaller hooks that can be used by the Base UI component. These hooks should not apply any logic that is Base UI-incompatible (for example when creating an event callback, it should not call the equivalent prop, because this will be handled later down the line in the Base UI codebase).

@flaviendelangle flaviendelangle self-assigned this Mar 13, 2025
Copy link

github-actions bot commented Mar 13, 2025

Thanks for adding a type label to the PR! 👍

@flaviendelangle flaviendelangle added core Infrastructure work going on behind the scenes component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature and removed core Infrastructure work going on behind the scenes labels Mar 13, 2025
@mui-bot
Copy link

mui-bot commented Mar 13, 2025

Deploy preview: https://deploy-preview-16944--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 604b485

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 17, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 17, 2025
@flaviendelangle flaviendelangle added maintenance and removed enhancement This is not a bug, nor a new feature labels Mar 17, 2025
@flaviendelangle flaviendelangle marked this pull request as ready for review March 18, 2025 06:23
@flaviendelangle flaviendelangle merged commit 8ca7f61 into mui:master Mar 19, 2025
25 checks passed
@flaviendelangle flaviendelangle deleted the useField-clean branch March 19, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants