Close client instructions panel on outside click
All checks were successful
Build and Deploy Gateway / build-and-push (push) Successful in 9s
Build and Deploy Gateway / deploy (push) Successful in 1s

This commit is contained in:
2026-07-11 12:36:30 +03:00
parent fa3b455fab
commit 42c15df8c9

View File

@@ -97,6 +97,8 @@ export function ClientOverviewPage({
const subscriptionInputRef = useRef(null);
const subscriptionRef = useRef(null);
const copyTimerRef = useRef(null);
const instructionsPanelRef = useRef(null);
const instructionsToggleRef = useRef(null);
const serverKey = servers.map((server) => `${server.tag}:${server.server}:${server.server_port}`).join('|');
const gatewayAddress = isGateway ? window.location.hostname : '127.0.0.1';
const proxyUrls = localProxyUrls(state?.proxyPort, gatewayAddress);
@@ -210,6 +212,17 @@ export function ClientOverviewPage({
return () => document.removeEventListener('keydown', closeOnEscape);
}, [instructionsOpen]);
useEffect(() => {
if (!instructionsOpen) return undefined;
const closeInstructionsOutside = (event) => {
if (instructionsPanelRef.current?.contains(event.target)) return;
if (instructionsToggleRef.current?.contains(event.target)) return;
setInstructionsOpen(false);
};
document.addEventListener('pointerdown', closeInstructionsOutside);
return () => document.removeEventListener('pointerdown', closeInstructionsOutside);
}, [instructionsOpen]);
async function toggleConnection() {
const action = connectionAction({ connected, selectedTag, configExists: state?.configExists });
if (action?.type === 'stop') return onStop();
@@ -278,6 +291,7 @@ export function ClientOverviewPage({
return (
<div className="client-shell">
{hasSubscription && <button
ref={instructionsToggleRef}
className={`client-instructions-toggle${instructionsOpen ? ' is-open' : ''}`}
type="button"
aria-expanded={instructionsOpen}
@@ -542,6 +556,7 @@ export function ClientOverviewPage({
</main>
{hasSubscription && <aside
ref={instructionsPanelRef}
id="client-instructions"
className={`client-instructions${instructionsOpen ? ' is-open' : ''}`}
aria-labelledby="instructions-title"