mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 16:28:31 +00:00
* 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
24 lines
896 B
JavaScript
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).
|
|
}
|
|
}
|