Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore horizontal scrolling of outputs for Firefox #15171

Merged
merged 14 commits into from
Oct 11, 2023
Merged
53 changes: 53 additions & 0 deletions galata/test/jupyterlab/print.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { expect, test } from '@jupyterlab/galata';
import * as path from 'path';

test.use({ autoGoto: false });

const fileName = 'simple_notebook.ipynb';

test.describe('Print layout', () => {
test('Notebook', async ({ page, tmpPath }) => {
await page.emulateMedia({ media: 'print' });
await page.contents.uploadFile(
path.resolve(__dirname, `./notebooks/${fileName}`),
`${tmpPath}/${fileName}`
);
await page.contents.uploadFile(
path.resolve(__dirname, './notebooks/WidgetArch.png'),
`${tmpPath}/WidgetArch.png`
);

await page.goto();

await page.notebook.openByPath(`${tmpPath}/${fileName}`);

await page.getByText('Python 3 (ipykernel) | Idle').waitFor();

await page.notebook.run();

let printedNotebookURL = '';
await Promise.all([
page.waitForRequest(
async request => {
const url = request.url();
if (url.match(/\/nbconvert\//) !== null) {
printedNotebookURL = url;
return true;
}
return false;
},
{ timeout: 1000 }
),
page.keyboard.press('Control+P')
]);

const newPage = await page.context().newPage();

await newPage.goto(printedNotebookURL, { waitUntil: 'networkidle' });

expect(await newPage.screenshot()).toMatchSnapshot('printed-notebook.png');

Check failure on line 51 in galata/test/jupyterlab/print.test.ts

View workflow job for this annotation

GitHub Actions / Visual Regression Tests

[jupyterlab] › test/jupyterlab/print.test.ts:12:7 › Print layout › Notebook

4) [jupyterlab] › test/jupyterlab/print.test.ts:12:7 › Print layout › Notebook ─────────────────── Error: Screenshot comparison failed: 6217 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/jupyterlab/jupyterlab/galata/test-results/test-jupyterlab-print-Print-layout-Notebook-jupyterlab/printed-notebook-expected.png Received: /home/runner/work/jupyterlab/jupyterlab/galata/test-results/test-jupyterlab-print-Print-layout-Notebook-jupyterlab/printed-notebook-actual.png Diff: /home/runner/work/jupyterlab/jupyterlab/galata/test-results/test-jupyterlab-print-Print-layout-Notebook-jupyterlab/printed-notebook-diff.png 49 | await newPage.goto(printedNotebookURL, { waitUntil: 'networkidle' }); 50 | > 51 | expect(await newPage.screenshot()).toMatchSnapshot('printed-notebook.png'); | ^ 52 | }); 53 | }); 54 | at /home/runner/work/jupyterlab/jupyterlab/galata/test/jupyterlab/print.test.ts:51:40

Check failure on line 51 in galata/test/jupyterlab/print.test.ts

View workflow job for this annotation

GitHub Actions / Visual Regression Tests

[jupyterlab] › test/jupyterlab/print.test.ts:12:7 › Print layout › Notebook

4) [jupyterlab] › test/jupyterlab/print.test.ts:12:7 › Print layout › Notebook ─────────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 6217 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/jupyterlab/jupyterlab/galata/test-results/test-jupyterlab-print-Print-layout-Notebook-jupyterlab-retry1/printed-notebook-expected.png Received: /home/runner/work/jupyterlab/jupyterlab/galata/test-results/test-jupyterlab-print-Print-layout-Notebook-jupyterlab-retry1/printed-notebook-actual.png Diff: /home/runner/work/jupyterlab/jupyterlab/galata/test-results/test-jupyterlab-print-Print-layout-Notebook-jupyterlab-retry1/printed-notebook-diff.png 49 | await newPage.goto(printedNotebookURL, { waitUntil: 'networkidle' }); 50 | > 51 | expect(await newPage.screenshot()).toMatchSnapshot('printed-notebook.png'); | ^ 52 | }); 53 | }); 54 | at /home/runner/work/jupyterlab/jupyterlab/galata/test/jupyterlab/print.test.ts:51:40
});
});
krassowski marked this conversation as resolved.
Show resolved Hide resolved
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 25 additions & 8 deletions packages/cells/style/inputarea.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@

/* All input areas */
.jp-InputArea {
display: table;
table-layout: fixed;
display: flex;
flex-direction: row;
width: 100%;
overflow: hidden;
}

.jp-InputArea-editor {
display: table-cell;
flex: 1 1 auto;
overflow: hidden;
vertical-align: top;

/* This is the non-active, default styling */
border: var(--jp-border-width) solid var(--jp-cell-editor-border-color);
Expand All @@ -27,8 +26,7 @@
}

.jp-InputPrompt {
display: table-cell;
vertical-align: top;
flex: 0 0 var(--jp-cell-prompt-width);
width: var(--jp-cell-prompt-width);
color: var(--jp-cell-inprompt-font-color);
font-family: var(--jp-cell-prompt-font-family);
Expand All @@ -52,17 +50,36 @@
user-select: none;
}

/*-----------------------------------------------------------------------------
| Print
|----------------------------------------------------------------------------*/
@media print {
.jp-InputArea {
display: table;
table-layout: fixed;
}

.jp-InputArea-editor {
display: table-cell;
vertical-align: top;
}

.jp-InputPrompt {
display: table-cell;
vertical-align: top;
}
}

/*-----------------------------------------------------------------------------
| Mobile
|----------------------------------------------------------------------------*/
@media only screen and (width <= 760px) {
.jp-InputArea-editor {
display: table-row;
margin-left: var(--jp-notebook-padding);
}

.jp-InputPrompt {
display: table-row;
flex: 0 0 auto;
text-align: left;
}
}
11 changes: 10 additions & 1 deletion packages/cells/style/widget.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@
width: calc(
var(--jp-cell-prompt-width) - var(--jp-private-cell-scrolling-output-offset)
);
flex: 0 0
calc(
var(--jp-cell-prompt-width) -
var(--jp-private-cell-scrolling-output-offset)
);
}

.jp-CodeCell.jp-mod-outputsScrolled .jp-OutputArea-promptOverlay {
Expand All @@ -117,7 +122,7 @@
|----------------------------------------------------------------------------*/

.jp-MarkdownOutput {
display: table-cell;
flex: 1 1 auto;
width: 100%;
margin-top: 0;
margin-bottom: 0;
Expand Down Expand Up @@ -235,4 +240,8 @@ cell outputs.
.jp-Cell-outputWrapper {
display: block;
}

.jp-MarkdownOutput {
display: table-cell;
}
}
10 changes: 10 additions & 0 deletions packages/notebook/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

.jp-Notebook .jp-Cell .jp-InputPrompt {
cursor: move;
float: left;
}

/*-----------------------------------------------------------------------------
Expand Down Expand Up @@ -458,3 +459,12 @@ div.jp-Cell-Placeholder-content-2 {
div.jp-Cell-Placeholder-content-3 {
top: 140px;
}

/*-----------------------------------------------------------------------------
| Printing
|----------------------------------------------------------------------------*/
@media print {
.jp-Notebook .jp-Cell .jp-InputPrompt {
float: none;
}
}
28 changes: 20 additions & 8 deletions packages/outputarea/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
}

.jp-OutputArea-child {
display: table;
table-layout: fixed;
display: flex;
flex-direction: row;
width: 100%;
overflow: hidden;
}

.jp-OutputPrompt {
width: var(--jp-cell-prompt-width);
flex: 0 0 var(--jp-cell-prompt-width);
color: var(--jp-cell-outprompt-font-color);
font-family: var(--jp-cell-prompt-font-family);
padding: var(--jp-code-padding);
Expand All @@ -43,13 +44,7 @@
user-select: none;
}

.jp-OutputArea-prompt {
display: table-cell;
vertical-align: top;
}

.jp-OutputArea-output {
display: table-cell;
width: 100%;
height: auto;
overflow: auto;
Expand Down Expand Up @@ -91,6 +86,11 @@
box-shadow: inset 0 0 1px var(--jp-inverse-layout-color0);
}

.jp-OutputArea-child .jp-OutputArea-output {
flex-grow: 1;
flex-shrink: 1;
}

/**
* Isolated output.
*/
Expand Down Expand Up @@ -198,6 +198,7 @@ body.lm-mod-override-cursor .jp-OutputArea-output.jp-mod-isolated::before {
.jp-OutputArea-output.jp-OutputArea-executeResult {
margin-left: 0;
width: 100%;
flex: 1 1 auto;
}

/* Text output with the Out[] prompt needs a top padding to match the
Expand Down Expand Up @@ -267,8 +268,19 @@ body.lm-mod-override-cursor .jp-OutputArea-output.jp-mod-isolated::before {

@media print {
.jp-OutputArea-child {
display: table;
table-layout: fixed;
break-inside: avoid-page;
}

.jp-OutputArea-prompt {
display: table-cell;
vertical-align: top;
}

.jp-OutputArea-output {
display: table-cell;
}
}

/*-----------------------------------------------------------------------------
Expand Down