Skip to content

Commit bd36001

Browse files
committed
#22 Fix back navigation on mobile
1 parent caa0401 commit bd36001

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

cypress/e2e/tasks.cy.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,17 @@ describe('Tasks', () => {
142142
cy.dontSee('Cook Ramen');
143143
});
144144

145+
it('Intercepts back navigation on mobile', () => {
146+
// Arrange
147+
cy.viewport('samsung-s10');
148+
cy.ariaLabel('Select task \\"Onboarding task\\"').click();
149+
cy.wait(500); // Wait panel to open
150+
151+
// Act
152+
cy.go('back');
153+
154+
// Assert
155+
cy.dontSee('Created on');
156+
});
157+
145158
});

src/pages/workspace/components/WorkspaceTask.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ import type { ElementSize } from '@aerogel/core';
229229
import Focus from '@/services/Focus';
230230
import Task from '@/models/Task';
231231
import Tasks from '@/services/Tasks';
232+
import { useWindowEvent } from '@/utils/composables';
232233
233234
import PanelAnimator from '@/pages/workspace/animations/PanelAnimator';
234235
@@ -369,6 +370,15 @@ useModelEvent(Task, 'updated', async (updatedTask) => {
369370
workspaceTask.value = undefined;
370371
});
371372
373+
useWindowEvent('popstate', (event) => {
374+
if (!event.state?.hideTask) {
375+
return;
376+
}
377+
378+
window.history.back();
379+
Tasks.select(null);
380+
});
381+
372382
watch(task, () => (editing.value = false));
373383
374384
watchEffect(async () => {
@@ -377,6 +387,9 @@ watchEffect(async () => {
377387
378388
await panelAnimator.show();
379389
390+
UI.mobile && window.history.pushState({ hideTask: true }, '', null);
391+
UI.mobile && window.history.pushState({}, '', null);
392+
380393
return;
381394
}
382395

0 commit comments

Comments
 (0)