Skip to content

Commit b17821e

Browse files
committed
Fix dismissed annoucement banner ignored when switching sites
1 parent 5b2bf82 commit b17821e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/gitbook/src/components/Announcement/AnnouncementDismissedScript.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import * as React from 'react';
34
import {
45
ANNOUNCEMENT_CSS_CLASS,
56
ANNOUNCEMENT_DAYS_TILL_RESET,
@@ -18,6 +19,15 @@ export function AnnouncementDismissedScript() {
1819
ANNOUNCEMENT_CSS_CLASS,
1920
]).slice(1, -1);
2021

22+
// makes sure keeps the banner state when navigating between sites
23+
React.useEffect(() => {
24+
checkStorageForDismissedScript(
25+
ANNOUNCEMENT_STORAGE_KEY,
26+
ANNOUNCEMENT_DAYS_TILL_RESET,
27+
ANNOUNCEMENT_CSS_CLASS
28+
);
29+
}, []);
30+
2131
return (
2232
<script
2333
suppressHydrationWarning

0 commit comments

Comments
 (0)