Skip to content

Commit 433556d

Browse files
flambohmaria-rcks
authored andcommitted
fix(web): closing a pane no longer blacks out the panes beside it (#29078)
1 parent 2c8c07a commit 433556d

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎apps/web/src/layout/SurfaceHost.tsx‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,16 @@ const NO_GHOSTS: ReadonlyMap<string, ClosingTab> = new Map();
185185
* Pane edges land on whole pixels, so borders and text stay crisp at any split.
186186
* Both panes round the same boundary, so the gap between them stays exact.
187187
*/
188-
function slotStyle(slot: LayoutPaneSlot): React.CSSProperties {
188+
function slotStyle(slot: LayoutPaneSlot, stripPx?: number): React.CSSProperties {
189189
const edge = (has: boolean) => (has ? HALF_PANE_GAP : "0px");
190190
const at = (fraction: number, offset: string) =>
191191
`round(calc(${fraction * 100}% + ${offset}), 1px)`;
192-
const left = at(slot.rect.left, edge(slot.hasLeft));
193-
const right = at(slot.rect.left + slot.rect.width, `-1 * ${edge(slot.hasRight)}`);
192+
const across = (fraction: number, offset: string) =>
193+
stripPx === undefined
194+
? at(fraction, offset)
195+
: `round(calc(${fraction * stripPx}px + ${offset}), 1px)`;
196+
const left = across(slot.rect.left, edge(slot.hasLeft));
197+
const right = across(slot.rect.left + slot.rect.width, `-1 * ${edge(slot.hasRight)}`);
194198
const top = at(slot.rect.top, edge(slot.hasAbove));
195199
const bottom = at(slot.rect.top + slot.rect.height, `-1 * ${edge(slot.hasBelow)}`);
196200
return {
@@ -1056,6 +1060,7 @@ export function LayoutSurfaceHost({
10561060
chats: chatTabsById,
10571061
launchers: launcherTabsById,
10581062
placed: slotByTabId,
1063+
stripPx,
10591064
motionKey: paneMotionKey,
10601065
framed: paneCount > 1 || maximizedTabId !== null,
10611066
});
@@ -1068,6 +1073,7 @@ export function LayoutSurfaceHost({
10681073
chats: chatTabsById,
10691074
launchers: launcherTabsById,
10701075
placed: slotByTabId,
1076+
stripPx,
10711077
motionKey: paneMotionKey,
10721078
framed: paneCount > 1 || maximizedTabId !== null,
10731079
});
@@ -1080,8 +1086,9 @@ export function LayoutSurfaceHost({
10801086
seen.motionKey === paneMotionKey
10811087
) {
10821088
const closed: [string, ClosingTab][] = [];
1083-
for (const [tabId, placed] of seen.placed) {
1089+
for (const [tabId, was] of seen.placed) {
10841090
if (presentTabIds.has(tabId) || ghosts.has(tabId)) continue;
1091+
const placed = { slot: was.slot, style: slotStyle(was.slot, seen.stripPx) };
10851092
const chat = seen.chats.get(tabId);
10861093
const launcher = seen.launchers.get(tabId);
10871094
if (chat?.tab.content.kind === "chat") {

‎apps/web/src/motion/paneMotion.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const translate = (dx: number, dy: number): Keyframe => ({
3838
/** How far a new pane slides out from under its donor, in px. */
3939
const OPEN_TRAVEL_PX = 48;
4040

41+
const ADJACENT_GAP_PX = 16;
42+
4143
/** The Panel animations setting's default, which plays niri's springs as they are. */
4244
const DEFAULT_PANEL_MS = 150;
4345

@@ -145,7 +147,7 @@ function findDonor(
145147
);
146148
}
147149
for (const [side, gap] of gaps) {
148-
if (gap < -1) continue;
150+
if (gap < -1 || gap > ADJACENT_GAP_PX) continue;
149151
const rank = (candidate: { neighbour: Neighbour; side: Side }) =>
150152
(candidate.neighbour.other &&
151153
resized(candidate.side, candidate.neighbour.box, candidate.neighbour.other)

0 commit comments

Comments
 (0)