Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
dist
node_modules
package-lock.json
# Generated by tests and coverage, the same folders as in .gitignore
coverage
test-results
playwright-report
blob-report
3 changes: 2 additions & 1 deletion frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { defineConfig, globalIgnores } from 'eslint/config';
import prettier from 'eslint-config-prettier';

export default defineConfig([
globalIgnores(['dist']),
// Built and generated files, the same folders as in .gitignore.
globalIgnores(['dist', 'coverage', 'test-results', 'playwright-report', 'blob-report']),
{
files: ['**/*.{ts,tsx}'],
extends: [
Expand Down
15 changes: 8 additions & 7 deletions frontend/src/features/auth/components/AuthForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ export function AuthForm({ mode, onSubmit }: AuthFormProps) {
const [formError, setFormError] = useState('');
const [working, setWorking] = useState(false);
const id = useId();
const inputs = {
username: useRef<HTMLInputElement>(null),
password: useRef<HTMLInputElement>(null),
};
// Two plain refs, passed straight to `ref`. Keeping them in an object and reading
// `inputs.password` while rendering breaks the react-hooks/refs rule (React Compiler).
const usernameInput = useRef<HTMLInputElement>(null);
const passwordInput = useRef<HTMLInputElement>(null);
const isRegister = mode === 'register';

/** Shows the messages and moves focus to the first field that has one. */
function showFieldErrors(errors: FieldErrors) {
setFieldErrors(errors);
const first = FIELDS.find((field) => errors[field]);
if (first) inputs[first].current?.focus();
if (first === 'username') usernameInput.current?.focus();
else if (first === 'password') passwordInput.current?.focus();
}

async function handleSubmit(event: FormEvent<HTMLFormElement>) {
Expand Down Expand Up @@ -102,7 +103,7 @@ export function AuthForm({ mode, onSubmit }: AuthFormProps) {
</p>
)}
<input
ref={inputs.username}
ref={usernameInput}
id={`${id}-username`}
name="username"
value={values.username}
Expand Down Expand Up @@ -130,7 +131,7 @@ export function AuthForm({ mode, onSubmit }: AuthFormProps) {
</p>
)}
<input
ref={inputs.password}
ref={passwordInput}
id={`${id}-password`}
name="password"
type="password"
Expand Down