Skip to content

Commit 8605b1e

Browse files
authored
Various fixes for docked Drawer variant sizing/positioning (#709)
1 parent 5a43c8d commit 8605b1e

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

src/panel_material_ui/layout/Drawer.jsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,13 @@ export function render({model, view}) {
128128
if (!inline) { return }
129129
if (isDocked) {
130130
if (isHorizontal) {
131-
view.el.style.width = open ? `${size + TAB_SIZE}px` : `${TAB_SIZE}px`
131+
view.el.style.width = open ? `${size + TAB_SIZE}px` : "0px"
132132
view.el.style.height = "100%"
133+
view.el.style.overflow = "visible"
133134
} else {
134-
view.el.style.height = open ? `${size + TAB_SIZE}px` : `${TAB_SIZE}px`
135+
view.el.style.height = open ? `${size + TAB_SIZE}px` : "0px"
135136
view.el.style.width = "100%"
137+
view.el.style.overflow = "visible"
136138
}
137139
} else {
138140
if (isHorizontal) {
@@ -147,13 +149,16 @@ export function render({model, view}) {
147149

148150
if (isDocked) {
149151
if (inline) {
150-
// Inline docked: same structure as fixed docked but scoped to a relative container.
152+
// Inline docked: container collapses to 0 when closed; the tab is absolutely
153+
// positioned so it overlays adjacent content rather than pushing it.
151154
const containerStyle = {
152155
position: "relative",
153-
[isHorizontal ? "width" : "height"]: open ? `${size + TAB_SIZE}px` : `${TAB_SIZE}px`,
156+
[isHorizontal ? "width" : "height"]: open ? `${size + TAB_SIZE}px` : "0px",
154157
[isHorizontal ? "height" : "width"]: "100%",
155158
transition: "width 225ms cubic-bezier(0, 0, 0.2, 1), height 225ms cubic-bezier(0, 0, 0.2, 1)",
159+
overflow: "visible",
156160
pointerEvents: "none",
161+
flexShrink: 0,
157162
}
158163

159164
const innerStyle = {
@@ -163,6 +168,19 @@ export function render({model, view}) {
163168
pointerEvents: "auto",
164169
}
165170

171+
const closedTabStyle = (() => {
172+
const offsetSide = anchor === "left" ? "right" : anchor === "right" ? "left" : anchor === "top" ? "bottom" : "top"
173+
return {
174+
position: "absolute",
175+
[offsetSide]: `-${TAB_SIZE}px`,
176+
...getPositionStyle(anchor, dockPosition),
177+
width: isHorizontal ? `${TAB_SIZE}px` : `${TAB_LENGTH}px`,
178+
height: isHorizontal ? `${TAB_LENGTH}px` : `${TAB_SIZE}px`,
179+
pointerEvents: "auto",
180+
zIndex: 1200,
181+
}
182+
})()
183+
166184
return (
167185
<div style={containerStyle}>
168186
<div style={innerStyle}>
@@ -181,7 +199,9 @@ export function render({model, view}) {
181199
<DockedTab anchor={anchor} open={open} dockPosition={dockPosition} attached onClick={() => setOpen(false)} />
182200
</Drawer>
183201
{!open && (
184-
<DockedTab anchor={anchor} open={false} dockPosition={dockPosition} attached={false} onClick={() => setOpen(true)} />
202+
<div style={closedTabStyle}>
203+
<DockedTab anchor={anchor} open={false} dockPosition={dockPosition} inline attached={false} onClick={() => setOpen(true)} />
204+
</div>
185205
)}
186206
</div>
187207
</div>

0 commit comments

Comments
 (0)