Skip to content

[SignInPage] Allow slotProps to override all labels#4418

Merged
bharatkashyap merged 15 commits intomui:masterfrom
bharatkashyap:fix/override-labels
Nov 21, 2024
Merged

[SignInPage] Allow slotProps to override all labels#4418
bharatkashyap merged 15 commits intomui:masterfrom
bharatkashyap:fix/override-labels

Conversation

@bharatkashyap
Copy link
Collaborator

@bharatkashyap bharatkashyap commented Nov 15, 2024

@bharatkashyap bharatkashyap added the type: bug It doesn't behave as expected. 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
Collaborator 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
Collaborator 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 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug It doesn't behave as expected.

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