Skip to content

Commit d99e6bb

Browse files
authored
Merge pull request xtermjs#5718 from xtermjs/anthonykim1/fixZindex
Fix image addon overriding screen element z-index
2 parents 0b6220e + 579a0a5 commit d99e6bb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

addons/addon-image/src/ImageRenderer.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,19 +340,22 @@ export class ImageRenderer extends Disposable implements IDisposable {
340340
);
341341
canvas.classList.add(`xterm-image-layer-${layer}`);
342342
const screenElement = this._terminal._core.screenElement;
343+
// Use isolation to create a stacking context without overriding z-index,
344+
// which would conflict with integrators (e.g. VS Code) that set their
345+
// own z-index on the screen element.
346+
screenElement.style.isolation = 'isolate';
343347
if (layer === 'bottom') {
344348
// Use z-index:-1 so it paints behind non-positioned text elements.
345-
// The screen element needs to be a stacking context to contain the
346-
// negative z-index, otherwise it would go behind the entire terminal.
349+
// The screen element needs to be a stacking context (via isolation)
350+
// to contain the negative z-index, otherwise it would go behind the
351+
// entire terminal.
347352
canvas.style.zIndex = '-1';
348-
screenElement.style.zIndex = '0';
349353
screenElement.insertBefore(canvas, screenElement.firstChild);
350354
} else {
351355
// Explicit z-index ensures the image canvas reliably stacks above
352356
// the text layer (DOM renderer rows). z-index: 0 is below the
353357
// selection overlay (z-index: 1).
354358
canvas.style.zIndex = '0';
355-
screenElement.style.zIndex = '0';
356359
screenElement.appendChild(canvas);
357360
}
358361
const ctx = canvas.getContext('2d', { alpha: true, desynchronized: true });

0 commit comments

Comments
 (0)