Trening: auto-przewijanie do nastepnej serii do uzupelnienia po zapisie i przy wejsciu w sesje
This commit is contained in:
@@ -179,6 +179,7 @@ function SetRow({
|
||||
.join(' · ');
|
||||
return (
|
||||
<div
|
||||
id={`set-${set.id}`}
|
||||
className={
|
||||
isNext
|
||||
? 'rounded-[10px] border border-dashed border-accent/55 bg-accent/5 px-3 py-3'
|
||||
@@ -527,6 +528,13 @@ export default function DayExecution() {
|
||||
|
||||
const toggleEx = (id: string) =>
|
||||
setExpandedIds((cur) => (cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id]));
|
||||
|
||||
// Auto-nawigacja: przy zmianie „następnej" serii (też po zapisie) rozwinięte
|
||||
// ćwiczenie przewija widok do niej — bez ręcznego szukania kolejnej serii.
|
||||
useEffect(() => {
|
||||
if (!nextSetId) return;
|
||||
document.getElementById(`set-${nextSetId}`)?.scrollIntoView?.({ behavior: 'smooth', block: 'center' });
|
||||
}, [nextSetId, expandedIds]);
|
||||
const editSetData = editSet ? allSets.find((s) => s.id === editSet.setId) : undefined;
|
||||
const editValues: SetFieldValues = editSetData
|
||||
? {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { render, screen, within } from '@testing-library/react';
|
||||
import { render, screen, waitFor, within } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
@@ -362,6 +362,24 @@ describe('Kolejka serii w sesji', () => {
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('przewija widok do następnej serii do uzupełnienia (auto-nawigacja)', async () => {
|
||||
const spy = vi.fn();
|
||||
const orig = Element.prototype.scrollIntoView;
|
||||
Element.prototype.scrollIntoView = spy;
|
||||
mockApi({ 'ss-1': 10, 'ss-2': null, 'ss-3': null });
|
||||
const user = userEvent.setup();
|
||||
try {
|
||||
renderApp();
|
||||
await openActiveDay(user);
|
||||
|
||||
// następna seria to ss-2 (w rozwiniętym automatycznie ćwiczeniu) — na nią scroll
|
||||
await waitFor(() => expect(spy).toHaveBeenCalled());
|
||||
expect(spy.mock.contexts).toContain(document.getElementById('set-ss-2'));
|
||||
} finally {
|
||||
Element.prototype.scrollIntoView = orig;
|
||||
}
|
||||
});
|
||||
|
||||
it('odblokowuje „Dodaj serię” dla ćwiczenia bez normy mimo niedokończonej normy innego ćwiczenia', async () => {
|
||||
mockApi({ 'ss-1': 10, 'ss-2': null, 'ss-3': 12 });
|
||||
const user = userEvent.setup();
|
||||
|
||||
Reference in New Issue
Block a user