mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
Hide the dev toolbar on print (#11496)
* Hide the dev toolbar on print * Run checkset * Add a test case
This commit is contained in:
parent
ee21ac761f
commit
53ccd206f9
3 changed files with 34 additions and 0 deletions
5
.changeset/orange-boats-trade.md
Normal file
5
.changeset/orange-boats-trade.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Hide the dev toolbar on `window.print()` (CTRL + P)
|
|
@ -413,4 +413,28 @@ test.describe('Dev Toolbar', () => {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('hidden on print media', async ({ page, astro }) => {
|
||||
await page.goto(astro.resolveUrl('/'));
|
||||
|
||||
const toolbar = page.locator('astro-dev-toolbar');
|
||||
|
||||
const settingsAppButton = toolbar.locator('button[data-app-id="astro:settings"]');
|
||||
await settingsAppButton.click();
|
||||
|
||||
const settingsAppCanvas = toolbar.locator(
|
||||
'astro-dev-toolbar-app-canvas[data-app-id="astro:settings"]'
|
||||
);
|
||||
const settingsWindow = settingsAppCanvas.locator('astro-dev-toolbar-window');
|
||||
await expect(settingsWindow).toBeVisible();
|
||||
|
||||
await page.emulateMedia({ media: 'print' });
|
||||
await expect(settingsWindow).not.toBeVisible();
|
||||
|
||||
await page.emulateMedia({ media: 'screen' });
|
||||
await expect(settingsWindow).toBeVisible();
|
||||
|
||||
await settingsAppButton.click();
|
||||
await expect(settingsWindow).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -49,6 +49,11 @@ export class AstroDevToolbar extends HTMLElement {
|
|||
z-index: 999999;
|
||||
view-transition-name: astro-dev-toolbar;
|
||||
display: contents;
|
||||
|
||||
/* Hide the dev toolbar on window.print() (CTRL + P) */
|
||||
@media print {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
::view-transition-old(astro-dev-toolbar),
|
||||
|
|
Loading…
Reference in a new issue