You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The format of each local storage entry is also different, e.g.
Two panel layout:
{ "left": 50, "right": 50 }
Three panel layout:
{ "left": 33, "center": 33, "right": 34 }
Conceptually, version 4 should be able to detect and automatically "migrate" older entries to the newer format.
Note
If the version 4 hook is used without an explicit array of panel ids, the local storage key is the same. If panel ids are provided, the legacy key name can still be known and queried for values.
The unspoken challenge here is that if the panelIds array is omitted, and the legacy layout contains more than one layout, the version 4 hook has no way to know which layout to use, so it would have to just bail out and return undefined.
Given a
PanelGroupwith an auto-save id of "persistence", version 3 of this library saved layouts in an object that looked like this:{ "left,right": { "expandToSizes": {}, "layout": [50, 50] }, "center,left,right": { "expandToSizes": {}, "layout": [33, 33, 34] } }The
useDefaultLayouthook in version 4 saves layouts in a different format.The first difference is that layouts are saved as separate entries, depending on the ids provided, for more flexibility.
idpanelIdslocalStoragekey"persistence"undefined"react-resizable-panels:persistence""persistence"[ "left", "right" ]"react-resizable-panels:persistence:left:right""persistence"[ "left", "center", "right" ]"react-resizable-panels:persistence:left:center:right"The format of each local storage entry is also different, e.g.
Two panel layout:
{ "left": 50, "right": 50 }Three panel layout:
{ "left": 33, "center": 33, "right": 34 }Conceptually, version 4 should be able to detect and automatically "migrate" older entries to the newer format.
Note
If the version 4 hook is used without an explicit array of panel ids, the local storage key is the same. If panel ids are provided, the legacy key name can still be known and queried for values.
The unspoken challenge here is that if the
panelIdsarray is omitted, and the legacy layout contains more than one layout, the version 4 hook has no way to know which layout to use, so it would have to just bail out and returnundefined.I think the high level logic then should be:
flowchart TD START[useDefaultLayout] --> IDS{Has panel ids?} IDS -->|No| IDS_NO{Saved data?} IDS_NO -->|Yes| IDS_NO_VERSION{Which version?} IDS_NO_VERSION -->|Version 4| IDS_NO_VERSION_4[Use layout] IDS_NO_VERSION -->|Version 3| IDS_NO_VERSION_3[How many layouts?] IDS_NO_VERSION_3 -->|1 layout| IDS_NO_VERSION_3_1[Convert legacy layout] IDS_NO_VERSION_3 -->|2+ layouts| IDS_NO_VERSION_3_MORE[No default layout] IDS_NO -->|No| IDS_NO_UNDEFINED[No default layout] IDS -->|Yes| IDS_YES{Saved data?} IDS_YES -->|Yes| IDS_YES_VERSION{Which version?} IDS_YES_VERSION -->|Version 4| IDS_YES_VERSION_4[Use layout] IDS_YES_VERSION -->|Version 3| IDS_YES_VERSION_3[Convert legacy layout] IDS_YES -->|No| IDS_YES_FALLBACK[Check for legacy data]