[PR #1368] [MERGED] fix: prevent null history.state errors in modal routing and task navigation #4917

Closed
opened 2026-04-16 13:21:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/1368
Author: @Copilot
Created: 8/31/2025
Status: Merged
Merged: 8/31/2025
Merged by: @kolaente

Base: mainHead: copilot/fix-1359


📝 Commits (5)

  • 0124efc Initial plan
  • 7871e58 fix: add optional chaining to prevent null history.state error
  • 356c7f2 fix: prevent null history.state errors in modal routing and task navigation
  • bf9b6fe Delete frontend/package-lock.json
  • bafa490 Delete frontend/src/composables/useRouteWithModal.test.ts

📊 Changes

2 files changed (+2 additions, -2 deletions)

View changed files

📝 frontend/src/composables/useRouteWithModal.ts (+1 -1)
📝 frontend/src/views/tasks/TaskDetailView.vue (+1 -1)

📄 Description

This PR resolves the JavaScript error "Error can't access property 'backdropView', window.history.state is null" that users encounter when signing in, navigating directly to task URLs, or reloading task pages.

Problem

When users navigate directly to a task URL (e.g., typing the URL in the address bar) or reload a task page, window.history.state becomes null. The existing code attempts to access properties on this null value:

// This throws "Cannot read properties of null" when history.state is null
const backdropView = computed(() => route.fullPath ? window.history.state.backdropView : undefined)

Solution

Added optional chaining (?.) to safely access history.state properties:

// This returns undefined gracefully when history.state is null
const backdropView = computed(() => route.fullPath ? window.history.state?.backdropView : undefined)

Changes

  • frontend/src/composables/useRouteWithModal.ts: Added optional chaining to window.history.state?.backdropView
  • frontend/src/views/tasks/TaskDetailView.vue: Added optional chaining to router.options.history.state?.back
  • frontend/src/composables/useRouteWithModal.test.ts: Added comprehensive unit tests to verify null state handling

Impact

Users can navigate directly to task URLs without errors
Page reloads on task pages work correctly
Signin flow no longer shows error popups
Existing modal navigation functionality preserved

This fix follows the established pattern already used elsewhere in the same file and is consistent with modern JavaScript best practices for null safety.

Fixes #1359.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: node index.js --exec install (dns block)
  • googlechromelabs.github.io
    • Triggering command: node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.204/linux64/chrome-headless-shell-linux64.zip
    • Triggering command: node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:


Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/1368 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 8/31/2025 **Status:** ✅ Merged **Merged:** 8/31/2025 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `copilot/fix-1359` --- ### 📝 Commits (5) - [`0124efc`](https://github.com/go-vikunja/vikunja/commit/0124efcb890dcbd9c9c79d76bd27b1df955ac0b2) Initial plan - [`7871e58`](https://github.com/go-vikunja/vikunja/commit/7871e585a327569b71eb116462edc76f9aec9323) fix: add optional chaining to prevent null history.state error - [`356c7f2`](https://github.com/go-vikunja/vikunja/commit/356c7f210ef4cb9c28998eaefdc70adc4718149f) fix: prevent null history.state errors in modal routing and task navigation - [`bf9b6fe`](https://github.com/go-vikunja/vikunja/commit/bf9b6fefc9c325dd418f51ff8d4861ecc45854ba) Delete frontend/package-lock.json - [`bafa490`](https://github.com/go-vikunja/vikunja/commit/bafa490c4a86a894b3018153d6fd6283399efd84) Delete frontend/src/composables/useRouteWithModal.test.ts ### 📊 Changes **2 files changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/composables/useRouteWithModal.ts` (+1 -1) 📝 `frontend/src/views/tasks/TaskDetailView.vue` (+1 -1) </details> ### 📄 Description This PR resolves the JavaScript error "Error can't access property 'backdropView', window.history.state is null" that users encounter when signing in, navigating directly to task URLs, or reloading task pages. ## Problem When users navigate directly to a task URL (e.g., typing the URL in the address bar) or reload a task page, `window.history.state` becomes `null`. The existing code attempts to access properties on this null value: ```typescript // This throws "Cannot read properties of null" when history.state is null const backdropView = computed(() => route.fullPath ? window.history.state.backdropView : undefined) ``` ## Solution Added optional chaining (`?.`) to safely access `history.state` properties: ```typescript // This returns undefined gracefully when history.state is null const backdropView = computed(() => route.fullPath ? window.history.state?.backdropView : undefined) ``` ## Changes - **`frontend/src/composables/useRouteWithModal.ts`**: Added optional chaining to `window.history.state?.backdropView` - **`frontend/src/views/tasks/TaskDetailView.vue`**: Added optional chaining to `router.options.history.state?.back` - **`frontend/src/composables/useRouteWithModal.test.ts`**: Added comprehensive unit tests to verify null state handling ## Impact ✅ Users can navigate directly to task URLs without errors ✅ Page reloads on task pages work correctly ✅ Signin flow no longer shows error popups ✅ Existing modal navigation functionality preserved This fix follows the established pattern already used elsewhere in the same file and is consistent with modern JavaScript best practices for null safety. Fixes #1359. > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses (expand for details)</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `download.cypress.io` > - Triggering command: `node index.js --exec install` (dns block) > - `googlechromelabs.github.io` > - Triggering command: `node install.mjs` (dns block) > - `https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.204/linux64/chrome-headless-shell-linux64.zip` > - Triggering command: `node install.mjs` (http block) > > If you need me to access, download, or install something from one of these locations, you can either: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to the custom allowlist in this repository's [Copilot coding agent settings](https://github.com/go-vikunja/vikunja/settings/copilot/coding_agent) (admins only) > > </details> <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/go-vikunja/vikunja/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 13:21:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#4917