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

[SignInPage] Allow slotProps to override all labels #4418

Merged
merged 15 commits into from
Nov 21, 2024

Conversation

bharatkashyap
Copy link
Member

@bharatkashyap bharatkashyap commented Nov 15, 2024

@bharatkashyap bharatkashyap added the bug 🐛 Something doesn't work label Nov 15, 2024
Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

What was the reason for not using the label prop on the TextField and rendering instead a different label component?

Also, when spreading the slotProps, make sure that the complex prop are being merged, like slotProps, className, style prop etc.

@bharatkashyap
Copy link
Member Author

What was the reason for not using the label prop on the TextField and rendering instead a different label component?

Agree, no reason to be doing it this way.

Also, when spreading the slotProps, make sure that the complex prop are being merged, like slotProps, className, style prop etc.

Got it, I've updated to use a common function that can take care of merging props for all of the <TextField /> components in the page

Comment on lines 48 to 61
htmlInput: {
sx: {
paddingTop: theme.spacing(1),
paddingBottom: theme.spacing(1),
},
...baseProps.slotProps?.htmlInput,
},
inputLabel: {
sx: {
lineHeight: theme.typography.pxToRem(12),
fontSize: theme.typography.pxToRem(14),
},
...baseProps.slotProps?.inputLabel,
},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
htmlInput: {
sx: {
paddingTop: theme.spacing(1),
paddingBottom: theme.spacing(1),
},
...baseProps.slotProps?.htmlInput,
},
inputLabel: {
sx: {
lineHeight: theme.typography.pxToRem(12),
fontSize: theme.typography.pxToRem(14),
},
...baseProps.slotProps?.inputLabel,
},
htmlInput: {
...baseProps.slotProps?.htmlInput,
sx: [
{
paddingTop: theme.spacing(1),
paddingBottom: theme.spacing(1),
},
...(Array.isArray(baseProps.slotProps?.htmlInput?.sx) ? baseProps.slotProps?.htmlInput?.sx : [baseProps.slotProps?.htmlInput?.sx
},
inputLabel: {
...baseProps.slotProps?.inputLabel,
sx: [
{
lineHeight: theme.typography.pxToRem(12),
fontSize: theme.typography.pxToRem(14),
},
...(Array.isArray(baseProps.slotProps?.inputLabel?.sx) ? baseProps.slotProps?.inputLabel?.sx : [baseProps.slotProps?.inputLabel?.sx
],
},
},

You can extract the sx prop into variables so we don't repeat the expressions.

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Left one last comment, the rest looks much better 👌

@@ -40,6 +39,29 @@ import FusionAuthIcon from './icons/FusionAuth';
import { BrandingContext, RouterContext } from '../shared/context';
import { DocsContext } from '../internal/context';
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a red flag (making the logic depend on something related to the docs), unless I am misunderstanding the usage.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was done to help render demos smoothly in the docs. It's used in two places, mostly to do with UI:

  • Not setting autoFocus true if the component is being used in the docs
  • Setting the loading state of the Credentials form to false even if the login is unsuccessful (also the case in the docs)

Agreed that it's not the cleanest way - I can make a note to remove these and tackle that in one of the upcoming releases 👍🏻

@bharatkashyap bharatkashyap merged commit 3ecf527 into mui:master Nov 21, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unwanted "Email" label on the sign-in page when specifying slot props for the email field
2 participants