Skip to content

Commit 126045a

Browse files
authored
Merge pull request #244 from Point72/tkp/hf
Configure title to reset layout, fix default restore issue
2 parents ce9743d + 7251a63 commit 126045a

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

js/src/components/header.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,18 @@ export function Header(props) {
7272
{/* Left */}
7373
<div className="row">
7474
{headerLogo}
75-
<h1 className="header-title">{openapi?.info.title}</h1>
75+
<a
76+
href="/"
77+
onClick={(e) => {
78+
e.preventDefault();
79+
const url = new URL(window.location);
80+
url.searchParams.delete("layout");
81+
window.history.replaceState(null, "", url);
82+
window.location.reload();
83+
}}
84+
>
85+
<h1 className="header-title">{openapi?.info.title}</h1>
86+
</a>
7687
<p className="header-version">{openapi?.info.version}</p>
7788
</div>
7889

js/src/components/perspective/workspace.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const Workspace = forwardRef(function Workspace(
3737
const wsRef = useRef(null);
3838
const [layouts, setLayouts] = useState({});
3939
const [activeLayoutName, setActiveLayoutName] = useState(null);
40+
const [restoreCount, setRestoreCount] = useState(0);
4041
const initializedRef = useRef(false);
4142

4243
// ── Imperative handle for Header and other consumers ──────────────
@@ -46,7 +47,10 @@ export const Workspace = forwardRef(function Workspace(
4647
getLayouts: () => layouts,
4748
getActiveLayout: () => activeLayoutName,
4849
setActiveLayout: (name) => {
49-
if (layouts[name]) setActiveLayoutName(name);
50+
if (layouts[name]) {
51+
setActiveLayoutName(name);
52+
setRestoreCount((c) => c + 1);
53+
}
5054
},
5155
saveLayout: async () => {
5256
const ws = wsRef.current;
@@ -166,7 +170,7 @@ export const Workspace = forwardRef(function Workspace(
166170
if (!ws) return;
167171

168172
ws.restore(applyThemeToLayout(layouts[activeLayoutName]));
169-
}, [activeLayoutName]);
173+
}, [activeLayoutName, restoreCount]);
170174

171175
// ── Apply theme to newly added viewers (right-click → add table) ──
172176
// Only fires AFTER initial restore is complete (guarded by initializedRef)

js/src/style/header_footer.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
border-bottom: 1px solid var(--border);
1717
}
1818

19+
.header a {
20+
color: unset;
21+
text-decoration: none;
22+
}
23+
1924
.header-title {
2025
margin-left: 10px;
2126
}

0 commit comments

Comments
 (0)