fix: nepřepínání dnů/týdnů při otevřené minihře
CI / Generate TypeScript types (push) Successful in 11s
CI / Server unit tests (push) Successful in 27s
CI / Build server (push) Successful in 32s
CI / Build client (push) Successful in 42s
CI / Playwright E2E tests (push) Successful in 2m38s
CI / Build and push Docker image (push) Successful in 45s
CI / Notify (push) Successful in 2s
CI / Generate TypeScript types (push) Successful in 11s
CI / Server unit tests (push) Successful in 27s
CI / Build server (push) Successful in 32s
CI / Build client (push) Successful in 42s
CI / Playwright E2E tests (push) Successful in 2m38s
CI / Build and push Docker image (push) Successful in 45s
CI / Notify (push) Successful in 2s
This commit is contained in:
1 parent
95a35df6ab
commit
fe12098ed0
5 files changed
+20
-4
No files matched your search
@@ -30,6 +30,7 @@ import PendingPayments from './components/PendingPayments';
|
||||
import { useEasterEgg } from './context/eggs';
|
||||
import { ClientData, Food, MealSlot, PendingQr, PizzaOrder, DepartureTime, PizzaDayState, Restaurant, RestaurantDayMenu, RestaurantDayMenuMap, LunchChoice, LocationLunchChoicesMap, UserLunchChoice, PizzaVariant, getData, getEasterEggImage, addPizza, removePizza, updatePizzaDayNote, createPizzaDay, deletePizzaDay, lockPizzaDay, unlockPizzaDay, finishOrder, finishDelivery, addChoice, jdemeObed, removeChoices, removeChoice, updateNote, changeDepartureTime, setBuyer, generateQr } from '../../types';
|
||||
import { getLunchChoiceName } from './enums';
|
||||
import { isArrowNavigationBlocked } from './utils/arrowNavigation';
|
||||
// import FallingLeaves, { LEAF_PRESETS, LEAF_COLOR_THEMES } from './FallingLeaves';
|
||||
// import './FallingLeaves.scss';
|
||||
|
||||
@@ -244,6 +245,7 @@ function App() {
|
||||
|
||||
// Navigace mezi dny pomocí klávesových šípek
|
||||
const handleKeyDown = useCallback((e: any) => {
|
||||
if (isArrowNavigationBlocked(e)) return;
|
||||
if (e.keyCode === 37 && dayIndex != null && dayIndex > 0) {
|
||||
handleDayChange(dayIndex - 1);
|
||||
} else if (e.keyCode === 39 && dayIndex != null && dayIndex < 4) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import BoltSimulationModal from '../components/modals/BoltSimulationModal';
|
||||
import GenerateMockOrdersModal from '../components/modals/GenerateMockOrdersModal';
|
||||
import PendingPayments from '../components/PendingPayments';
|
||||
import OrderProgress, { PROVIDER_LABEL } from '../components/OrderProgress';
|
||||
import { isArrowNavigationBlocked } from '../utils/arrowNavigation';
|
||||
|
||||
const SLOT = MealSlot.EXTRA;
|
||||
const TIME_REGEX = /^([01]\d|2[0-3]):[0-5]\d$/;
|
||||
@@ -224,9 +225,8 @@ export default function OrderGroupsPage() {
|
||||
|
||||
// Navigace mezi dny pomocí klávesových šipek (←/→), obdobně jako na hlavní stránce
|
||||
const handleKeyDown = useCallback((e: KeyboardEvent) => {
|
||||
// Ignorujeme, pokud uživatel právě píše do formulářového pole
|
||||
const tag = (e.target as HTMLElement)?.tagName;
|
||||
if (tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA') return;
|
||||
// Ignorujeme, pokud uživatel právě píše do formulářového pole nebo je otevřený dialog (např. minihra)
|
||||
if (isArrowNavigationBlocked(e)) return;
|
||||
const currentIso = data?.isoDate;
|
||||
if (!currentIso) return;
|
||||
if (e.keyCode === 37) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Legend, Line, LineChart, Tooltip, XAxis, YAxis } from "recharts";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { getLunchChoiceName } from "../enums";
|
||||
import './StatsPage.scss';
|
||||
import { isArrowNavigationBlocked } from '../utils/arrowNavigation';
|
||||
|
||||
const CHART_WIDTH = 1400;
|
||||
const CHART_HEIGHT = 700;
|
||||
@@ -131,6 +132,7 @@ export default function StatsPage() {
|
||||
}, [dateRange]);
|
||||
|
||||
const handleKeyDown = useCallback((e: any) => {
|
||||
if (isArrowNavigationBlocked(e)) return;
|
||||
if (e.keyCode === 37) {
|
||||
handlePreviousWeek();
|
||||
} else if (e.keyCode === 39 && !isCurrentOrFutureWeek) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Zda se má stisk klávesy ignorovat pro navigaci šipkami mezi dny/týdny na pozadí stránky.
|
||||
* Navigace se nemá provádět, pokud uživatel píše do formulářového pole, nebo pokud je otevřený
|
||||
* modální dialog (typicky minihra jako Tetris či Had, která šipky používá k ovládání) –
|
||||
* jinak by se stránka na pozadí neustále přepínala a zbytečně přenačítala data ze serveru.
|
||||
*/
|
||||
export function isArrowNavigationBlocked(e: KeyboardEvent): boolean {
|
||||
const target = e.target as HTMLElement | null;
|
||||
if (target?.closest?.('input, textarea, select, [contenteditable="true"]')) return true;
|
||||
return document.body.classList.contains('modal-open') || document.querySelector('.modal.show') != null;
|
||||
}
|
||||
Reference in new issue
Block a user