Skip to content

Fix dismissed annoucement banner ignored when switching sites #3057

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

Merged
merged 3 commits into from
Mar 28, 2025

Conversation

valentin0h
Copy link
Contributor

@valentin0h valentin0h commented Mar 27, 2025

Fixes an issue in v2 where the announcement banner would reappear during client-side navigation between routes despite being previously dismissed. The fix complements the existing page-load script with useEffect that reapplies the banner's dismissed state after next navigation updates the DOM.

before

CleanShot.2025-03-28.at.08.34.26.mp4

after

CleanShot.2025-03-28.at.08.02.31.mp4

Copy link

changeset-bot bot commented Mar 27, 2025

⚠️ No Changeset found

Latest commit: 4aad1fc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Mar 27, 2025

Copy link

argos-ci bot commented Mar 27, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v1 (Inspect) ✅ No changes detected - Mar 28, 2025, 7:49 AM
customers-v2 (Inspect) ✅ No changes detected - Mar 28, 2025, 7:51 AM
default (Inspect) 👍 Changes approved 6 changed Mar 28, 2025, 7:52 AM
v2-vercel (Inspect) ✅ No changes detected - Mar 28, 2025, 7:54 AM

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where a dismissed announcement banner would reappear during client-side navigation by reapplying the dismissed state using a useEffect hook.

  • Added a useEffect hook to reapply the dismissed state on route changes
  • Updated the AnnouncementDismissedScript.tsx file to include the new behavior
Comments suppressed due to low confidence (1)

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

  • [nitpick] Consider importing useEffect directly (e.g., 'import { useEffect } from "react";') to clarify the dependency usage and potentially reduce bundle size.
import * as React from 'react';

@valentin0h valentin0h marked this pull request as ready for review March 28, 2025 07:42
@valentin0h valentin0h merged commit 0f41e19 into main Mar 28, 2025
18 checks passed
@valentin0h valentin0h deleted the banner-keep-dismissed-srate branch March 28, 2025 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants