[PR #1072] [MERGED] Clean up __history usage #3501

Closed
opened 2026-02-28 20:42:33 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/1072
Author: @j-f1
Created: 5/29/2023
Status: Merged
Merged: 6/20/2023
Merged by: @j-f1

Base: trevdor-react-router-6-part-2Head: jed/dunder-navigate


📝 Commits (5)

  • 72c0b12 Replace window.__history with history in upgrade-notifications.ts
  • 10655a0 Disable menu item actions for now
  • 3e22afd Replace __history with __navigate
  • 6b72b64 effect
  • a7cd5ed Add in import

📊 Changes

10 files changed (+52 additions, -46 deletions)

View changed files

📝 packages/desktop-client/src/components/FinancesApp.js (+3 -5)
📝 packages/desktop-client/src/components/LoggedInUser.js (+3 -3)
📝 packages/desktop-client/src/components/manager/ConfigServer.js (+1 -1)
📝 packages/desktop-client/src/components/manager/ManagementApp.js (+2 -1)
📝 packages/desktop-client/src/global-events.js (+7 -5)
packages/desktop-client/src/util/ExposeNavigate.js (+10 -0)
📝 packages/desktop-electron/menu.js (+3 -1)
📝 packages/loot-core/src/client/actions/budgets.ts (+1 -1)
📝 packages/loot-core/src/client/upgrade-notifications.ts (+21 -25)
📝 packages/loot-core/typings/window.d.ts (+1 -4)

📄 Description

This introduces a new global __navigate function connected to the current router. This is useful when swapping between routers (such as when opening/closing a file) or when doing menu actions from within Electron.

There’s still an issue here around how modals work. Presently, modals are represented as a linked list, with the user-visible URL displaying the URL of the topmost modal, and a chain of locationPtr objects in state that go through the open modals in order, before eventually ending up on the page that forms the backdrop of all open modals. This approach has a couple of downsides:

  • If you refresh the page while a modal is open, the modal will fill the screen
    • This does not always happen; for example, the Create Account modal does not interact with the router at all, but the Create Schedule button does do this
    • Some modals (such as Create Schedule) break if they are opened before the page behind them can load
  • Naïve components (including the sidebar) will lose the selected state because they only look at the URL of the topmost modal, while they should actually be looking at the last element of the linked location list.

Here are a couple of directions we could take to alleviate these issues:

  • Switch to a query param (like ?modal[]=/schedule/discover&modal[]=/foo/bar) that displays open modals in the URL while also preserving the full history chain upon reload
  • Store the modal stack entirely in some sort of global state so that the URL never changes when opening a modal

What do you think about these options? (also, we can move this discussion to an issue/discord/another forum if desired)


🔄 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/actualbudget/actual/pull/1072 **Author:** [@j-f1](https://github.com/j-f1) **Created:** 5/29/2023 **Status:** ✅ Merged **Merged:** 6/20/2023 **Merged by:** [@j-f1](https://github.com/j-f1) **Base:** `trevdor-react-router-6-part-2` ← **Head:** `jed/dunder-navigate` --- ### 📝 Commits (5) - [`72c0b12`](https://github.com/actualbudget/actual/commit/72c0b1244c5516460db03b9543577db781ccb85e) Replace window.__history with history in upgrade-notifications.ts - [`10655a0`](https://github.com/actualbudget/actual/commit/10655a07f0547d120b0c811aef1d7f70ab2d606f) Disable menu item actions for now - [`3e22afd`](https://github.com/actualbudget/actual/commit/3e22afd0961524cd716d99dcbfac87e1ce84ce9a) Replace __history with __navigate - [`6b72b64`](https://github.com/actualbudget/actual/commit/6b72b64b61933150cb82bd819ada1ee582adbc90) effect - [`a7cd5ed`](https://github.com/actualbudget/actual/commit/a7cd5ed8f0ffa3171bbd9125b5fe7996816bed3e) Add in import ### 📊 Changes **10 files changed** (+52 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `packages/desktop-client/src/components/FinancesApp.js` (+3 -5) 📝 `packages/desktop-client/src/components/LoggedInUser.js` (+3 -3) 📝 `packages/desktop-client/src/components/manager/ConfigServer.js` (+1 -1) 📝 `packages/desktop-client/src/components/manager/ManagementApp.js` (+2 -1) 📝 `packages/desktop-client/src/global-events.js` (+7 -5) ➕ `packages/desktop-client/src/util/ExposeNavigate.js` (+10 -0) 📝 `packages/desktop-electron/menu.js` (+3 -1) 📝 `packages/loot-core/src/client/actions/budgets.ts` (+1 -1) 📝 `packages/loot-core/src/client/upgrade-notifications.ts` (+21 -25) 📝 `packages/loot-core/typings/window.d.ts` (+1 -4) </details> ### 📄 Description This introduces a new global `__navigate` function connected to the current router. This is useful when swapping between routers (such as when opening/closing a file) or when doing menu actions from within Electron. There’s still an issue here around how modals work. Presently, modals are represented as a linked list, with the user-visible URL displaying the URL of the topmost modal, and a chain of `locationPtr` objects in state that go through the open modals in order, before eventually ending up on the page that forms the backdrop of all open modals. This approach has a couple of downsides: - If you refresh the page while a modal is open, the modal will fill the screen - This does not always happen; for example, the Create Account modal does not interact with the router at all, but the Create Schedule button does do this - Some modals (such as Create Schedule) break if they are opened before the page behind them can load - Naïve components (including the sidebar) will lose the selected state because they only look at the URL of the topmost modal, while they should actually be looking at the last element of the linked location list. Here are a couple of directions we could take to alleviate these issues: - Switch to a query param (like `?modal[]=/schedule/discover&modal[]=/foo/bar`) that displays open modals in the URL while also preserving the full history chain upon reload - Store the modal stack entirely in some sort of global state so that the URL never changes when opening a modal What do you think about these options? (also, we can move this discussion to an issue/discord/another forum if desired) --- <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-02-28 20:42:33 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#3501