feat(a11y): cross-platform hardening + modal focus-trap from impeccable audit

Responsive / viewport:
- add .min-h-viewport / .h-viewport utilities (100dvh + Telegram --tg-viewport-stable-height)
- migrate min-h-screen / h-screen / 100vh across 18 files
- reveal hover-only controls on focus-within + touch (desktop nav, admin settings)
- grid breakpoints (TopUpAmount, Contests), larger touch targets, nav aria-labels

Platform routing (Telegram WebView correctness):
- clipboard -> copyToClipboard util with execCommand fallback (10 files)
- window.open -> openTelegramLink / openLink (Profile, Referral, ChannelSubscriptionScreen)
- window.confirm -> useNativeDialog (admin pages); PromoOffersSection -> useDestructiveConfirm
- window.prompt -> usePrompt / PromptDialogHost (TipTap link editors)
- ESLint no-restricted-properties guard against regressions (adapters/clipboard util exempt)

Modal accessibility:
- new useFocusTrap hook (focus trap, Esc, scroll lock, focus restore)
- role=dialog / aria-modal / focus-trap: Polls, SuccessNotificationModal, AdminPolicies,
  AdminPromoGroups, AdminCampaigns, BroadcastPreview (Telegram + Email)
- new global usePrompt store + PromptDialogHost
This commit is contained in:
c0mrade
2026-05-25 23:16:07 +03:00
parent 2bcba3b60f
commit 8e0b63bac8
48 changed files with 584 additions and 173 deletions

60
src/store/promptDialog.ts Normal file
View File

@@ -0,0 +1,60 @@
import { create } from 'zustand';
export interface PromptOptions {
/** Field label shown above the input. */
label: string;
/** Optional heading. */
title?: string;
initialValue?: string;
placeholder?: string;
submitLabel?: string;
cancelLabel?: string;
/** Input type, e.g. 'text' (default) or 'url'. */
inputType?: string;
}
interface PromptRequest extends PromptOptions {
resolve: (value: string | null) => void;
}
interface PromptState {
request: PromptRequest | null;
/**
* Open a prompt dialog and resolve with the entered value, or null if cancelled.
* Cross-platform replacement for window.prompt (which is unavailable in the Telegram WebView).
*/
prompt: (options: PromptOptions) => Promise<string | null>;
submit: (value: string) => void;
cancel: () => void;
}
export const usePromptStore = create<PromptState>((set, get) => ({
request: null,
prompt: (options) =>
new Promise<string | null>((resolve) => {
// If a prompt is already open, cancel it before replacing.
const existing = get().request;
if (existing) existing.resolve(null);
set({ request: { ...options, resolve } });
}),
submit: (value) => {
const req = get().request;
if (!req) return;
req.resolve(value);
set({ request: null });
},
cancel: () => {
const req = get().request;
if (!req) return;
req.resolve(null);
set({ request: null });
},
}));
/** Returns a stable function that opens a prompt dialog and resolves with the value (or null). */
export function usePrompt() {
return usePromptStore((s) => s.prompt);
}