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] Refactor Data Grid with Date Pickers example #15992

Merged
merged 4 commits into from
Dec 27, 2024

Conversation

LukasTy
Copy link
Member

@LukasTy LukasTy commented Dec 23, 2024

Created from an investigation on #15965 and #15967.

@LukasTy LukasTy added docs Improvements or additions to the documentation component: data grid This is the name of the generic UI component, not the React module! component: pickers This is the name of the generic UI component, not the React module! labels Dec 23, 2024
@LukasTy LukasTy requested review from flaviendelangle, michelengelen and a team December 23, 2024 16:22
@LukasTy LukasTy self-assigned this Dec 23, 2024
@mui-bot
Copy link

mui-bot commented Dec 23, 2024

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

Generated by 🚫 dangerJS against 31ad8e3

<InputLabel htmlFor={id} id={inputLabelId} {...InputLabelProps}>
{label}
</InputLabel>
{label != null && label !== '' && (
Copy link
Member Author

Choose a reason for hiding this comment

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

Aligning with TextField on @mui/material: https://github.com/mui/material-ui/blob/c3f36426ccbb34368b084fd4b3c5ac65cee43b3e/packages/mui-material/src/TextField/TextField.js#L243
@noraleonte was there a reason to always render a label element in Picker's case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not entirely sure 🤔 But only rendering when there is a label prop makes more sense 👍 🙈

slots={{ textField: WrappedGridEditDateInput }}
slotProps={{
textField: {
variant: 'standard',
Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like it's doable with slotProps, isn't it smoother and preferred over slots overriding when possible?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @LukasTy , I've tried relying on accessible DOM structure here f6e6eee but ran into accessibility warning when input receives focus, Does #15985 solves that?

Copy link
Member Author

Choose a reason for hiding this comment

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

@k-rajat19 Yes, that change aims to solve the exact "problem" of calling inputRef.focus() and not seeing any effect, because the input is a hidden element aimed to store the bound value on the accessible DOM.
We'll see if there are no objections to that approach, given that it could be seen as somewhat "hacky". 🙈


IMHO, we should keep using the autoFocus prop for that particular demo to minimize the code.
If we want to demo editMode="row", the autoFocus should be removed as no explicit field focusing is needed in this mode.

},
},
}}
slotProps={{ textField: { size: 'small' } }}
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix this visual inconsistency. 🙈
Screenshot 2024-12-23 at 18 26 27

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for catching this

Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

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

Looking good! :shipit:

Would love a review from @noraleonte though!

@@ -81,7 +65,20 @@ function GridEditDateCell({
value={value}
autoFocus
onChange={handleChange}
slots={{ textField: WrappedGridEditDateInput }}
slotProps={{
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Is there a way to force the "shrink" state for the floating label on pickers? If so, would be good to add it for consistency.

Picker field:
Screenshot 2024-12-24 at 13 40 27

Text field:
Screenshot 2024-12-24 at 13 40 15

Copy link
Member Author

Choose a reason for hiding this comment

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

Sadly, Pickers with accessibleFieldDOMStructure do not support placeholder prop just like the native date input or React Spectrum fields.
It's not possible, because there is no input element. 🙈

Copy link
Contributor

@noraleonte noraleonte left a comment

Choose a reason for hiding this comment

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

🚀 💙

@LukasTy LukasTy merged commit dcdc59e into mui:master Dec 27, 2024
24 checks passed
@LukasTy LukasTy deleted the fix-pickers-text-field-usage- branch December 27, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! 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.

7 participants