mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2026-08-08 02:02:33 +00:00
Re-split library and preview when the editor is hidden; remember the editor's width
This commit is contained in:
@@ -51,6 +51,16 @@ export function PaneToggleStrip() {
|
||||
preview: previewVisible,
|
||||
};
|
||||
|
||||
// The strip's own element — its parent is the panes row, so we can measure the
|
||||
// width available to the panes (row minus this strip) when toggling the editor,
|
||||
// which needs it to remember/restore the editor's width (PanesStore.togglePane).
|
||||
const stripRef = useRef<HTMLDivElement>(null);
|
||||
const panesInner = (): number => {
|
||||
const strip = stripRef.current;
|
||||
const row = strip?.parentElement;
|
||||
return row ? row.clientWidth - strip.offsetWidth : 0;
|
||||
};
|
||||
|
||||
// Roving tabindex over the toggles + the trailing Datasets action (the divider
|
||||
// is not a control). One tab stop; the focused index is the only `tabIndex=0`.
|
||||
const count = PANES.length + 1;
|
||||
@@ -88,6 +98,7 @@ export function PaneToggleStrip() {
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={stripRef}
|
||||
role="toolbar"
|
||||
aria-orientation="vertical"
|
||||
aria-label="Workspace panes"
|
||||
@@ -117,7 +128,7 @@ export function PaneToggleStrip() {
|
||||
.filter(Boolean)
|
||||
.join(' ')}
|
||||
onClick={() => {
|
||||
togglePane(item.pane);
|
||||
togglePane(item.pane, panesInner());
|
||||
setFocusIndex(i);
|
||||
}}
|
||||
onKeyDown={(e) => onKeyDown(e, i)}
|
||||
|
||||
Reference in New Issue
Block a user