@redsift/table 12.5.5 → 12.5.6-muiv8-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1570,15 +1570,22 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
1570
1570
|
}
|
|
1571
1571
|
let logicOperator = GridLogicOperator.And;
|
|
1572
1572
|
let quickFilterValues = [];
|
|
1573
|
+
// Whether the URL carries explicit filter metadata (`_logicOperator` /
|
|
1574
|
+
// `_quickFilterValues`). Distinguishes an explicit empty filter (which the
|
|
1575
|
+
// grid serialises with `_logicOperator`) from a URL that has no filter params
|
|
1576
|
+
// at all, so the latter can fall through to localStorage. (ODM-3149)
|
|
1577
|
+
let hasFilterMeta = false;
|
|
1573
1578
|
const searchParams = new URLSearchParams();
|
|
1574
1579
|
for (const [key, value] of new URLSearchParams(searchString)) {
|
|
1575
1580
|
if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility', '_pagination', '_quickFilterValues', '_columnOrder', '_rowGrouping', '_aggregation', '_pivot', '_density', '_filters'].includes(key)) {
|
|
1576
1581
|
searchParams.set(key, value);
|
|
1577
1582
|
}
|
|
1578
1583
|
if (key === '_logicOperator') {
|
|
1584
|
+
hasFilterMeta = true;
|
|
1579
1585
|
logicOperator = value === GridLogicOperator.And || value === GridLogicOperator.Or ? value : GridLogicOperator.And;
|
|
1580
1586
|
}
|
|
1581
1587
|
if (key === '_quickFilterValues') {
|
|
1588
|
+
hasFilterMeta = true;
|
|
1582
1589
|
try {
|
|
1583
1590
|
quickFilterValues = JSON.parse(decodeURIComponent(value));
|
|
1584
1591
|
} catch {
|
|
@@ -1633,6 +1640,16 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
1633
1640
|
if (isInvalid) {
|
|
1634
1641
|
return 'invalid';
|
|
1635
1642
|
}
|
|
1643
|
+
|
|
1644
|
+
// The URL carries no filter signal at all — no logic operator, no quick filter,
|
|
1645
|
+
// and no valid filter items (e.g. a bare `?period=30` written by another URL
|
|
1646
|
+
// owner before the grid mounts). This is NOT an explicit empty filter, so
|
|
1647
|
+
// return 'invalid' to let the caller fall through to localStorage instead of
|
|
1648
|
+
// returning an empty model that would overwrite the user's persisted filters
|
|
1649
|
+
// (and clobber localStorage on the way out). (ODM-3149)
|
|
1650
|
+
if (items.length === 0 && !hasFilterMeta) {
|
|
1651
|
+
return 'invalid';
|
|
1652
|
+
}
|
|
1636
1653
|
return {
|
|
1637
1654
|
items,
|
|
1638
1655
|
logicOperator,
|
|
@@ -1709,7 +1726,19 @@ const getSortingFromString = (searchString, columns) => {
|
|
|
1709
1726
|
}
|
|
1710
1727
|
const searchParams = new URLSearchParams(searchString);
|
|
1711
1728
|
const value = searchParams.get('_sortColumn');
|
|
1712
|
-
|
|
1729
|
+
|
|
1730
|
+
// `_sortColumn` absent entirely → the URL is not expressing sort state (e.g. it
|
|
1731
|
+
// only carries a foreign param such as `?period=30` written by another URL
|
|
1732
|
+
// owner before the grid mounts). Return 'invalid' so the caller falls through
|
|
1733
|
+
// to localStorage instead of returning an empty model that would clobber the
|
|
1734
|
+
// user's persisted sort. (ODM-3149)
|
|
1735
|
+
if (value === null) {
|
|
1736
|
+
return 'invalid';
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
// Explicit empty sort (`_sortColumn=` / `_sortColumn=[]`, written when the user
|
|
1740
|
+
// clears sorting) → respect it.
|
|
1741
|
+
if (value === '' || value === '[]') {
|
|
1713
1742
|
return [];
|
|
1714
1743
|
}
|
|
1715
1744
|
const fields = columns.map(column => column.field);
|