diff --git a/frontend/src/lib/lemon-ui/LemonInput/LemonInput.tsx b/frontend/src/lib/lemon-ui/LemonInput/LemonInput.tsx index e946c4bd4d8df..d34ec50ed3a9e 100644 --- a/frontend/src/lib/lemon-ui/LemonInput/LemonInput.tsx +++ b/frontend/src/lib/lemon-ui/LemonInput/LemonInput.tsx @@ -41,6 +41,7 @@ interface LemonInputPropsBase transparentBackground?: boolean /** Size of the element. Default: `'medium'`. */ size?: 'small' | 'medium' + onPressEnter?: (event: React.KeyboardEvent) => void 'data-attr'?: string 'aria-label'?: string } @@ -50,7 +51,6 @@ export interface LemonInputPropsText extends LemonInputPropsBase { value?: string defaultValue?: string onChange?: (newValue: string) => void - onPressEnter?: (newValue: string) => void } export interface LemonInputPropsNumber @@ -60,7 +60,6 @@ export interface LemonInputPropsNumber value?: number defaultValue?: number onChange?: (newValue: number | undefined) => void - onPressEnter?: (newValue: number | undefined) => void } export type LemonInputProps = LemonInputPropsText | LemonInputPropsNumber @@ -152,15 +151,6 @@ export const LemonInput = React.forwardRef(fu className )} aria-disabled={textProps.disabled} - onKeyDown={(event) => { - if (onPressEnter && event.key === 'Enter') { - if (type === 'number') { - onPressEnter(value ?? 0) - } else { - onPressEnter(value?.toString() ?? '') - } - } - }} onClick={() => focus()} > {prefix} @@ -186,6 +176,11 @@ export const LemonInput = React.forwardRef(fu setFocused(false) onBlur?.(event) }} + onKeyDown={(event) => { + if (onPressEnter && event.key === 'Enter') { + onPressEnter(event) + } + }} {...textProps} /> {suffix} diff --git a/frontend/src/scenes/authentication/Login.tsx b/frontend/src/scenes/authentication/Login.tsx index f62d85bb826fb..883c3215db9bb 100644 --- a/frontend/src/scenes/authentication/Login.tsx +++ b/frontend/src/scenes/authentication/Login.tsx @@ -92,9 +92,13 @@ export function Login(): JSX.Element {

Log in

{generalError && ( - {generalError.detail || - ERROR_MESSAGES[generalError.code] || - 'Could not complete your login. Please try again.'} + {generalError.detail || ERROR_MESSAGES[generalError.code] || ( + <> + Could not complete your login. +
+ Please try again. + + )}
)}
@@ -107,8 +111,12 @@ export function Login(): JSX.Element { placeholder="email@yourcompany.com" type="email" onBlur={() => precheck({ email: login.email })} - onPressEnter={() => { + onPressEnter={(e) => { precheck({ email: login.email }) + if (isPasswordHidden) { + e.preventDefault() // Don't trigger submission if password field is still hidden + passwordInputRef.current?.focus() + } }} />