diff --git a/src/views/auth-onboarding-view.jsx b/src/views/auth-onboarding-view.jsx index ec758925..6f117850 100644 --- a/src/views/auth-onboarding-view.jsx +++ b/src/views/auth-onboarding-view.jsx @@ -825,6 +825,26 @@ export default function AuthOnboardingView({ onLoginRequest, onPersistenceChange, onImRegisterRequest, onError }) { const tenantName = sessionStorage.getItem('im-tenant-name') || ''; + + // errorText/errorLevel is one flat, top-level (tinode-web.jsx) piece of state shared by every + // view in the whole app -- it's never tied to which sidepanel is showing. Login is the only view + // here that already clears it on its own (its "切换企业" link calls onError() before navigating), + // because it was written knowing it can carry a leftover error INTO the tenant screen. Every other + // transition between these auth views was still missing that: submit a bad invite code on + // Register (errorText='邀请码错误,请重新输入', view stays 'register', shown correctly), then just + // click "已有账号?登录" -- Login mounts and, since it renders the exact same errorText/errorLevel + // props, shows that same registration error as if it were a login failure, with zero user action + // on this new page. Same the other way: a stale "账号或密码错误" from Login is still sitting there + // to greet a fresh Register visit. Fixing every call site that navigates between these views + // (TenantEntry/Login/Register/... several of which don't even receive onError as a prop today) + // would be a lot of scattered one-off edits for the same bug; clearing it centrally whenever the + // resolved `view` itself changes covers all of them (button clicks and browser back/forward alike) + // from the one place they all already funnel through. + React.useEffect(() => { + if (onError) onError(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [view]); + switch (view) { case 'tenant': return {})} />; case 'login': return