Skip to content

Commit

Permalink
Fix branding settings cache usage
Browse files Browse the repository at this point in the history
The branding settings are delivered as part of the initial hello and
then are cached in the state store. Any consumer must use the branding
settings from there instead from a potentially different hello state to
avoid loosing branding settings.

This fixes the flicker of the login form label and bottom text when the
login page is submitted.
  • Loading branch information
longsleep committed Nov 22, 2023
1 parent 539218f commit 00a079d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions identifier/src/containers/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const styles = theme => ({
function Login(props) {
const {
hello,
branding,
query,
dispatch,
history,
Expand Down Expand Up @@ -93,21 +94,21 @@ function Login(props) {
};

const usernamePlaceHolder = useMemo(() => {
if (hello?.details?.branding?.usernameHintText ) {
switch (hello.details.branding.usernameHintText) {
if (branding?.usernameHintText ) {
switch (branding.usernameHintText) {
case "Username":
break;
case "Email":
return t("konnect.login.usernameField.placeholder.email", "Email");
case "Identity":
return t("konnect.login.usernameField.placeholder.identity", "Identity");
default:
return hello.details.branding.usernameHintText;
return branding.usernameHintText;
}
}

return t("konnect.login.usernameField.placeholder.username", "Username");
}, [hello, t]);
}, [branding, t]);

return (
<DialogContent>
Expand Down Expand Up @@ -164,7 +165,7 @@ function Login(props) {
</Typography>
))}

{hello?.details?.branding?.signinPageText && <Typography variant="body2">{hello.details.branding.signinPageText}</Typography>}
{branding?.signinPageText && <Typography variant="body2">{branding.signinPageText}</Typography>}
</form>
</DialogContent>
);
Expand Down
2 changes: 1 addition & 1 deletion identifier/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const middlewares = [
thunkMiddleware
];

if (process.env.NODE_ENV === 'development') { // eslint-disable-line no-undef
if (process.env.NODE_ENV !== 'development') { // eslint-disable-line no-undef
middlewares.push(createLogger()); // must be last middleware in the chain.
}

Expand Down

0 comments on commit 00a079d

Please sign in to comment.