mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-19 22:12:13 +00:00
focus email only if the Intro route is focusable
This commit is contained in:
parent
f9273ffe07
commit
f1d06b7d37
1 changed files with 5 additions and 9 deletions
|
|
@ -1,8 +1,8 @@
|
|||
const React = require('react');
|
||||
const classnames = require('classnames');
|
||||
const UrlUtils = require('url');
|
||||
const Icon = require('stremio-icons/dom');
|
||||
const { Button, routesRegexp, useLocationHash } = require('stremio/common');
|
||||
const { useFocusable } = require('stremio-router');
|
||||
const { Button } = require('stremio/common');
|
||||
const CredentialsTextInput = require('./CredentialsTextInput');
|
||||
const ConsentCheckbox = require('./ConsentCheckbox');
|
||||
const styles = require('./styles');
|
||||
|
|
@ -11,11 +11,7 @@ const LOGIN_FORM = 'LOGIN_FORM';
|
|||
const SIGNUP_FORM = 'SIGNUP_FORM';
|
||||
|
||||
const Intro = () => {
|
||||
const locationHash = useLocationHash();
|
||||
const active = React.useMemo(() => {
|
||||
const { pathname: locationPathname } = UrlUtils.parse(locationHash.slice(1));
|
||||
return !!locationPathname.match(routesRegexp.intro.regexp);
|
||||
}, [locationHash]);
|
||||
const focusable = useFocusable();
|
||||
const emailRef = React.useRef();
|
||||
const passwordRef = React.useRef();
|
||||
const confirmPasswordRef = React.useRef();
|
||||
|
|
@ -141,10 +137,10 @@ const Intro = () => {
|
|||
}
|
||||
}, [state.error]);
|
||||
React.useEffect(() => {
|
||||
if (active) {
|
||||
if (focusable) {
|
||||
emailRef.current.focus();
|
||||
}
|
||||
}, [state.form, active]);
|
||||
}, [state.form, focusable]);
|
||||
return (
|
||||
<div className={styles['intro-container']}>
|
||||
<div className={styles['form-container']}>
|
||||
|
|
|
|||
Loading…
Reference in a new issue