Fix login button — use onPointerUp for cross-platform touch support
This commit is contained in:
+7
-5
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useRef } from 'react';
|
||||
import { useRef, useState } from 'react';
|
||||
|
||||
export default function LoginPage() {
|
||||
const [error, setError] = useState('');
|
||||
@@ -19,7 +19,7 @@ export default function LoginPage() {
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({ password }),
|
||||
});
|
||||
if (!res.ok) throw new Error('Invalid password');
|
||||
if (!res.ok) throw new Error('bad');
|
||||
window.location.href = '/';
|
||||
} catch {
|
||||
setError('Invalid password');
|
||||
@@ -58,9 +58,8 @@ export default function LoginPage() {
|
||||
ref={inputRef}
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
autoFocus
|
||||
autoComplete="current-password"
|
||||
onKeyDown={e => e.key === 'Enter' && handleLogin()}
|
||||
onKeyDown={e => { if (e.key === 'Enter') handleLogin(); }}
|
||||
style={{
|
||||
width: '100%',
|
||||
background: '#faf9f6',
|
||||
@@ -73,6 +72,7 @@ export default function LoginPage() {
|
||||
marginBottom: error ? '6px' : '16px',
|
||||
display: 'block',
|
||||
boxSizing: 'border-box',
|
||||
WebkitAppearance: 'none',
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -83,7 +83,7 @@ export default function LoginPage() {
|
||||
)}
|
||||
|
||||
<button
|
||||
onClick={handleLogin}
|
||||
onPointerUp={handleLogin}
|
||||
style={{
|
||||
width: '100%',
|
||||
background: '#2d5a3d',
|
||||
@@ -95,6 +95,8 @@ export default function LoginPage() {
|
||||
cursor: 'pointer',
|
||||
display: 'block',
|
||||
boxSizing: 'border-box',
|
||||
WebkitAppearance: 'none',
|
||||
touchAction: 'manipulation',
|
||||
}}
|
||||
>
|
||||
{loading ? 'Signing in...' : 'Sign in'}
|
||||
|
||||
Reference in New Issue
Block a user