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

Prevent the route announcer from being visible #8977

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/five-ads-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Prevent route announcer from being visible
17 changes: 15 additions & 2 deletions packages/astro/components/ViewTransitions.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@ export interface Props {
fallback?: Fallback;
}

const { fallback = 'animate' } = Astro.props as Props;
const { fallback = 'animate' } = Astro.props;
---

<style is:global>
/* Route announcer */
.astro-route-announcer {
position: absolute;
left: 0;
top: 0;
clip: rect(0 0 0 0);
clip-path: inset(50%);
overflow: hidden;
white-space: nowrap;
width: 1px;
height: 1px;
}
</style>
<meta name="astro-view-transitions-enabled" content="true" />
<meta name="astro-view-transitions-fallback" content={fallback} />
<script>
Expand Down
13 changes: 0 additions & 13 deletions packages/astro/components/viewtransitions.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,3 @@
animation: none !important;
}
}

/* Route announcer */
.astro-route-announcer {
position: absolute;
left: 0;
top: 0;
clip: rect(0 0 0 0);
clip-path: inset(50%);
overflow: hidden;
white-space: nowrap;
width: 1px;
height: 1px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
import { ViewTransitions } from 'astro:transitions';

---
<html>
<head>
<title>Testing</title>
<ViewTransitions />
</head>
<body>
<p id="one">One</p>
<a href="/no-directive-two">Go to 2</a>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
import { ViewTransitions } from 'astro:transitions';

---
<html>
<head>
<title>Testing</title>
<ViewTransitions />
</head>
<body>
<p id="two">Two</p>
</body>
</html>
20 changes: 17 additions & 3 deletions packages/astro/e2e/view-transitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ test.describe('View Transitions', () => {
});

test('client:only styles are retained on transition (1/2)', async ({ page, astro }) => {
const totalExpectedStyles = 8;
const totalExpectedStyles = 9;

await page.goto(astro.resolveUrl('/client-only-one'));
let msg = page.locator('.counter-message');
Expand All @@ -703,8 +703,8 @@ test.describe('View Transitions', () => {
});

test('client:only styles are retained on transition (2/2)', async ({ page, astro }) => {
const totalExpectedStyles_page_three = 10;
const totalExpectedStyles_page_four = 8;
const totalExpectedStyles_page_three = 11;
const totalExpectedStyles_page_four = 9;

await page.goto(astro.resolveUrl('/client-only-three'));
let msg = page.locator('#name');
Expand Down Expand Up @@ -887,4 +887,18 @@ test.describe('View Transitions', () => {
await locator.type(' World');
await expect(locator).toHaveValue('Hello World');
});

test('Route announcer is invisible on page transition', async ({ page, astro }) => {
await page.goto(astro.resolveUrl('/no-directive-one'));

let locator = page.locator('#one');
await expect(locator, 'should have content').toHaveText('One');

await page.click('a');
locator = page.locator('#two');
await expect(locator, 'should have content').toHaveText('Two');

let announcer = page.locator('.astro-route-announcer');
await expect(announcer, 'should have content').toHaveCSS('width', '1px');
});
});
Loading