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

[docs] New recipe of a read-only field #14606

Merged
merged 40 commits into from
Oct 7, 2024

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Sep 13, 2024

Closes #12342
Demo preview

It's a good opportunity to have a look at the overall DX of the most basic custom-behavior field possible.

In this PR

  • Create a new hook useFieldPlaceholder to generate the placeholder based on the format
  • Create a private context PickersFieldContext and a public hook usePickersFieldContext to pass information from the picker to the field without impacting the props (only one prop for now to open the field, name under discussion)
  • Improve the "Read only field" demo and move it in the public doc in a new custom-behavior folder (I will move the button and the autocomplete demos there once refined)

Follow up

  • Create doc sections to introduce useValidation, useFieldPlaceholder, usePickersFieldContext and useSplitFieldProps
  • Resume the work on the mask editing ([docs] Create Pickers masked field recipe #13515)
  • Update the existing demos (autocomplete, button, etc...) to use the new DX
  • Look which props we could move to usePickersFieldContext instead of drilling them down (would be breaking changes for v8).

@flaviendelangle flaviendelangle added docs Improvements or additions to the documentation component: pickers This is the name of the generic UI component, not the React module! labels Sep 13, 2024
@flaviendelangle flaviendelangle self-assigned this Sep 13, 2024
@mui-bot
Copy link

mui-bot commented Sep 13, 2024

@flaviendelangle flaviendelangle marked this pull request as ready for review September 13, 2024 07:54
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! 👏 💯
Leaving the final round of nitpicks. 🙈 😆

flaviendelangle and others added 6 commits October 7, 2024 13:07
…er.tsx

Co-authored-by: Lukas Tyla <llukas.tyla@gmail.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
…er.tsx

Co-authored-by: Lukas Tyla <llukas.tyla@gmail.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
…r.ts

Co-authored-by: Lukas Tyla <llukas.tyla@gmail.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
Co-authored-by: Lukas Tyla <llukas.tyla@gmail.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
Co-authored-by: Lukas Tyla <llukas.tyla@gmail.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
@flaviendelangle flaviendelangle merged commit b1a8dd4 into mui:master Oct 7, 2024
18 checks passed
@flaviendelangle flaviendelangle deleted the readonly-field branch October 7, 2024 12:31
InputProps={{
...InputProps,
readOnly: true,
endAdornment: <CalendarIcon color="action" />,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should have done this. 🙈
Now the keyboard navigation and a11y is borked. 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Tab sequence looks good to me, it does not focus the adornment anymore

I don't have the aria label on the TextField though, should probably add that (could be a nice addition in the context)

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! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs] Create a recipe of a read-only textfield field
4 participants