Ignore:
Timestamp:
06/11/22 23:50:19 (2 years ago)
Author:
anastasovv <simon@…>
Branches:
main
Children:
4a1a3ca
Parents:
87614a5
Message:

Code cleanings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • components/RegisterScreen.jsx

    r87614a5 r64dc53b  
    22
    33import { useSelector, useDispatch } from 'react-redux'
     4
     5import { useRef } from 'react'
    46
    57import { setStyle } from '../redux/reducers/styleSlice';
     
    810
    911const RegisterScreen = () => {
     12    const ref = useRef(null);
     13
    1014    const dispatch = useDispatch();
    1115
    1216    const styleState = useSelector(state => state.style);
     17
     18    setTimeout(() => {
     19        if (styleState.style.displayRegisterScreen && styleState.style.registerScreenInfo.setFocus) {
     20            ref.current.focus();
     21            dispatch(setStyle({
     22                ...styleState.style,
     23                registerScreenInfo: {
     24                    ...styleState.style.registerScreenInfo,
     25                    setFocus: false
     26                }
     27            }))
     28        }
     29    }, 10);
    1330
    1431    function onChangeUsername(e) {
     
    4057            }
    4158        }))
     59    }
     60
     61    function keyUp(e) {
     62        if (e.key === 'Enter') {
     63            register();
     64        }
    4265    }
    4366
     
    89112                            status: 'success',
    90113                        },
     114                        inlineAlertText: '',
    91115                    }));
    92116                }
     
    107131                <div>
    108132                    <span>Username:</span>
    109                     <input type="text" onChange={(e) => {onChangeUsername(e)}} value={styleState.style.registerScreenInfo.username}/>
     133                    <input ref={ref} type="text" onChange={(e) => {onChangeUsername(e)}} onKeyUp={(e) => keyUp(e)} value={styleState.style.registerScreenInfo.username} placeholder="your username..."/>
    110134                    <span>Display Name:</span>
    111                     <input type="text" onChange={(e) => {onChangeDisplayName(e)}} value={styleState.style.registerScreenInfo.displayName}/>
     135                    <input type="text" onChange={(e) => {onChangeDisplayName(e)}} onKeyUp={(e) => keyUp(e)} value={styleState.style.registerScreenInfo.displayName} placeholder="your display name..."/>
    112136                    <span>Password:</span>
    113                     <input type="password" onChange={(e) => {onChangePassword(e)}} value={styleState.style.registerScreenInfo.password}/>
     137                    <input type="password" onChange={(e) => {onChangePassword(e)}} onKeyUp={(e) => keyUp(e)} value={styleState.style.registerScreenInfo.password} placeholder="your password..."/>
    114138                    <div style={{width: '100%', display: 'flex', flexDirection: 'row', justifyContent: 'space-between'}}>
    115139                        <button className="primaryButton" onClick={() => closeForm()}>Close Form</button>
Note: See TracChangeset for help on using the changeset viewer.