Files
alamin-br 633f1c4b7d feat: remember last-opened row sidebar tab (comments/history) (#5687)
* feat: add helper to persist row edit modal sidebar tab

* test: spy on real localStorage so error-path tests exercise the catch

* feat: remember last-opened row edit modal sidebar tab (#2532)

* fix: persist the genuinely last-opened row sidebar tab

* chore: add changelog for remembered row sidebar tab

* refactor: tidy sidebar tab snapshot and assert no write on default mount

* refactor: address PR review — explicit no-op catch, shared localStorage test mock

* refactor: harden localStorage test mock with null-prototype store

* fix: keep sidebar tab preference when props deactivate it on a reused instance

* refactor: simplify sidebar tab persistence to a single reactive property
2026-07-09 15:56:41 +02:00

24 lines
896 B
JavaScript

// Persists the last-opened row edit modal sidebar tab, globally per browser.
// Access localStorage only through here so the backing store can be swapped
// later (e.g. to a cookie if the row modal ever becomes server-rendered).
export const ROW_EDIT_MODAL_SIDEBAR_TAB_KEY = 'baserow.rowEditModalSidebarTab'
// Returns the stored tab type string, or null when unset/unavailable.
export function getRowEditModalSidebarTab() {
try {
return localStorage.getItem(ROW_EDIT_MODAL_SIDEBAR_TAB_KEY) || null
} catch {
// Ignore storage errors (e.g. unavailable in private mode).
return null
}
}
// Stores the tab type string. No-op when localStorage is unavailable.
export function setRowEditModalSidebarTab(type) {
try {
localStorage.setItem(ROW_EDIT_MODAL_SIDEBAR_TAB_KEY, type)
} catch {
// Ignore storage errors (e.g. unavailable in private mode or over quota).
}
}