Skip to content

Commit 3e45cd7

Browse files
committed
Fixes #5165
1 parent 549fd24 commit 3e45cd7

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

src/shared/components/Contentful/PasswordScreen/index.jsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ export default class PasswordScreen extends React.Component {
2121

2222
onSubmit() {
2323
const { password } = this.props;
24-
const { inputVal } = this.state;
25-
this.setState({
26-
authorized: password === inputVal,
27-
errorMsg: password === inputVal ? '' : 'Password incorrect',
24+
this.setState((state) => {
25+
const { inputVal } = state;
26+
return {
27+
authorized: password === inputVal,
28+
errorMsg: password === inputVal ? '' : 'Password incorrect',
29+
};
2830
});
2931
}
3032

@@ -41,7 +43,7 @@ export default class PasswordScreen extends React.Component {
4143
authorized, errorMsg, inputVal,
4244
} = this.state;
4345
const {
44-
viewPortId, preview, spaceName, environment, baseUrl, title,
46+
viewPortId, preview, spaceName, environment, baseUrl, title, btnText,
4547
} = this.props;
4648
return authorized ? (
4749
<Viewport
@@ -62,9 +64,11 @@ export default class PasswordScreen extends React.Component {
6264
onChange={val => this.onPasswordInput(val)}
6365
errorMsg={errorMsg}
6466
required
67+
type="password"
68+
onEnterKey={this.onSubmit}
6569
/>
6670
<div styleName="cta">
67-
<button type="button" styleName="submit" onClick={this.onSubmit} disabled={!inputVal}>SUBMIT</button>
71+
<button type="button" styleName="submit" onClick={this.onSubmit} disabled={!inputVal}>{btnText}</button>
6872
</div>
6973
</div>
7074
</div>
@@ -78,6 +82,7 @@ PasswordScreen.defaultProps = {
7882
environment: null,
7983
baseUrl: '',
8084
title: 'GET ACCESS WITH PASSWORD',
85+
btnText: 'SUBMIT',
8186
};
8287

8388
PasswordScreen.propTypes = {
@@ -88,4 +93,5 @@ PasswordScreen.propTypes = {
8893
environment: PT.string,
8994
baseUrl: PT.string,
9095
title: PT.string,
96+
btnText: PT.string,
9197
};

src/shared/components/Contentful/Route.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function ChildRoutesLoader(props) {
7171
environment={environment}
7272
baseUrl={url}
7373
title={fields.passwordScreenTitle}
74+
btnText={fields.passwordScreenButtonText}
7475
/>
7576
)
7677
) : <Error404 />

src/shared/components/GUIKit/TextInput/index.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ function TextInput({
1717
onChange,
1818
required,
1919
size,
20+
type,
21+
onEnterKey,
2022
}) {
2123
const [val, setVal] = useState(value);
2224
const delayedOnChange = useRef(
@@ -28,7 +30,7 @@ function TextInput({
2830
<div className="textInputContainer" styleName={`container ${sizeStyle}`}>
2931
<input
3032
defaultValue={value}
31-
type="text"
33+
type={type}
3234
placeholder={`${placeholder}${placeholder && required ? ' *' : ''}`}
3335
styleName={`${value || val ? 'haveValue' : ''} ${errorMsg ? 'haveError' : ''}`}
3436
onChange={(e) => {
@@ -39,6 +41,11 @@ function TextInput({
3941
delayedOnChange(e.target.value, onChange);
4042
setVal(e.target.value);
4143
}}
44+
onKeyPress={(e) => {
45+
if (e.key === 'Enter') {
46+
onEnterKey();
47+
}
48+
}}
4249
/>
4350
{label ? (
4451
<label htmlFor="textBoxInput">
@@ -58,6 +65,8 @@ TextInput.defaultProps = {
5865
onChange: () => {},
5966
required: false,
6067
size: 'lg',
68+
type: 'text',
69+
onEnterKey: () => {},
6170
};
6271

6372
TextInput.propTypes = {
@@ -68,6 +77,8 @@ TextInput.propTypes = {
6877
onChange: PT.func,
6978
required: PT.bool,
7079
size: PT.oneOf(['xs', 'lg']),
80+
type: PT.string,
81+
onEnterKey: PT.func,
7182
};
7283

7384
export default TextInput;

0 commit comments

Comments
 (0)