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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hoist styles for Route Announcer 馃摙 #39331

Merged
merged 3 commits into from Aug 5, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 17 additions & 15 deletions packages/next/client/route-announcer.tsx
@@ -1,7 +1,22 @@
import React from 'react'
import { useRouter } from './router'

export function RouteAnnouncer() {
const nextjsRouteAnnouncerStyles: React.CSSProperties = {
border: 0,
clip: 'rect(0 0 0 0)',
height: '1px',
margin: '-1px',
overflow: 'hidden',
padding: 0,
position: 'absolute',
width: '1px',

// https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
whiteSpace: 'nowrap',
wordWrap: 'normal',
}

export const RouteAnnouncer = () => {
const { asPath } = useRouter()
const [routeAnnouncement, setRouteAnnouncement] = React.useState('')

Expand Down Expand Up @@ -39,20 +54,7 @@ export function RouteAnnouncer() {
aria-live="assertive" // Make the announcement immediately.
id="__next-route-announcer__"
role="alert"
style={{
border: 0,
clip: 'rect(0 0 0 0)',
height: '1px',
margin: '-1px',
overflow: 'hidden',
padding: 0,
position: 'absolute',
width: '1px',

// https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
whiteSpace: 'nowrap',
wordWrap: 'normal',
}}
style={nextjsRouteAnnouncerStyles}
>
{routeAnnouncement}
</p>
Expand Down