Skip to content

Commit

Permalink
fix(@clayui/core): fixes bug when rendering LiveAnnouncer on server side
Browse files Browse the repository at this point in the history
  • Loading branch information
matuzalemsteles committed Nov 21, 2023
1 parent ecf8214 commit 5765be2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/clay-core/src/live-announcer/LiveAnnouncer.tsx
Expand Up @@ -78,7 +78,7 @@ export const LiveAnnouncer = forwardRef<AnnouncerAPI>(function LiveAnnouncer(
[announce]
);

return createPortal(
const content = (
<VisuallyHidden liveAnnouncer>
<div aria-live="assertive" aria-relevant="additions" role="log">
{logs
Expand All @@ -94,7 +94,10 @@ export const LiveAnnouncer = forwardRef<AnnouncerAPI>(function LiveAnnouncer(
<div key={log.id}>{log.message}</div>
))}
</div>
</VisuallyHidden>,
document.body
</VisuallyHidden>
);

return typeof document !== 'undefined'
? createPortal(content, document.body)
: content;
});

0 comments on commit 5765be2

Please sign in to comment.