Skip to content

Commit 36054f1

Browse files
fix(hparams): persist table sort, filter, color, and selection across view switches
Lift the table's sort, filter, color-by, and row-selection state into HParamsPane so switching to the scatter matrix and back no longer resets them, matching the persistence the scatter matrix already has. HParamsTable becomes a controlled component driven by the parent-held state.
1 parent 334028e commit 36054f1

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

js/panes/HParamsPane.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ var HParamsPane = (props) => {
3838
const { content } = props;
3939
const data = readContent(content);
4040
const [view, setView] = useState('table');
41+
const [tableSort, setTableSort] = useState({ by: null, dir: null });
42+
const [tableFilter, setTableFilter] = useState('');
43+
const [tableColorBy, setTableColorBy] = useState(null);
44+
const [tableSelected, setTableSelected] = useState(() => new Set());
4145
const [splomDims, setSplomDims] = useState(null);
4246
const [splomColorBy, setSplomColorBy] = useState(null);
4347

@@ -117,6 +121,14 @@ var HParamsPane = (props) => {
117121
paramKeys={data.paramKeys}
118122
metricKeys={data.metricKeys}
119123
tagKeys={data.tagKeys}
124+
sort={tableSort}
125+
setSort={setTableSort}
126+
filter={tableFilter}
127+
setFilter={setTableFilter}
128+
colorBy={tableColorBy}
129+
setColorBy={setTableColorBy}
130+
selected={tableSelected}
131+
setSelected={setTableSelected}
120132
/>
121133
)}
122134
</div>

js/panes/hparams/HParamsTable.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import TreeSelect from 'rc-tree-select';
11-
import React, { useCallback, useMemo, useState } from 'react';
11+
import React, { useCallback, useMemo } from 'react';
1212

1313
import {
1414
buildColumns,
@@ -140,12 +140,20 @@ const HParamsRow = React.memo(function HParamsRow({
140140
);
141141
});
142142

143-
const HParamsTable = ({ records, paramKeys, metricKeys, tagKeys }) => {
144-
const [sort, setSort] = useState({ by: null, dir: null });
145-
const [filter, setFilter] = useState('');
146-
const [colorBy, setColorBy] = useState(null);
147-
const [selected, setSelected] = useState(() => new Set());
148-
143+
const HParamsTable = ({
144+
records,
145+
paramKeys,
146+
metricKeys,
147+
tagKeys,
148+
sort,
149+
setSort,
150+
filter,
151+
setFilter,
152+
colorBy,
153+
setColorBy,
154+
selected,
155+
setSelected,
156+
}) => {
149157
const columns = useMemo(
150158
() => buildColumns(paramKeys, metricKeys, tagKeys),
151159
[paramKeys, metricKeys, tagKeys]

0 commit comments

Comments
 (0)