feat(banner): add x for closing#9008
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryLow Risk Overview The site Reviewed by Cursor Bugbot for commit b2dc64f. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9008 +/- ##
==========================================
- Coverage 74.58% 74.54% -0.04%
==========================================
Files 100 100
Lines 8801 8801
Branches 324 325 +1
==========================================
- Hits 6564 6561 -3
- Misses 2233 2236 +3
Partials 4 4 ☔ View full report in Codecov by Harness. |
| const [dismissed, setDismissed] = useState(false); | ||
| if (dismissed) {return null;} |
There was a problem hiding this comment.
I don't think the banner needs to do its own state management, let the consumer of the component handle that with the onClose
There was a problem hiding this comment.
We could, however, that would require duplicating the state logic in doc-kit, and here
There was a problem hiding this comment.
I think that's fine, as we're going to need to tie this to a cookie/localStorage anyway
| transition-colors | ||
| hover:text-white; | ||
| } | ||
| } |
There was a problem hiding this comment.
Close button overlaps content
Medium Severity
The close control is absolute with right-4 while the banner still uses symmetric px-8 and centered content. Nothing reserves space for the button, so on narrower viewports or with longer banner text the label, link, or icon can sit under the ×. Elsewhere in this package, absolute controls get matching padding so content stays clear.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit bd140ea. Configure here.
📦 Build Size ComparisonSummary
Changes🔄 Modified Routes (4)
|
bjohansebas
left a comment
There was a problem hiding this comment.
I think that if we ever update the banner and a user previously dismissed it, we should show it to them again
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b2dc64f. Configure here.
| if (banner) { | ||
| setDismissed(localStorage.getItem(STORAGE_KEY) === banner.text); | ||
| } | ||
| }, [banner]); |
There was a problem hiding this comment.
Dismissed banner flashes on load
Medium Severity
Dismissal is restored from localStorage only inside useEffect, after the first paint. dismissed starts as false, so a previously closed banner still SSR-renders and shows briefly, then disappears and shifts the header/nav on every load.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b2dc64f. Configure here.
| > | ||
| <span aria-hidden="true">×</span> | ||
| </button> | ||
| )} |
There was a problem hiding this comment.
Close label not localizable
Low Severity
The close control hardcodes aria-label="Close banner" on the button, and that string is not overridable via props. Extra HTML attributes only spread onto the section, so consumers such as withBanner cannot pass a translated label despite already using useTranslations for the banner itself.
Reviewed by Cursor Bugbot for commit b2dc64f. Configure here.
| // rendered on the server and hidden after hydration if previously dismissed | ||
| useEffect(() => { | ||
| if (banner) { | ||
| setDismissed(localStorage.getItem(STORAGE_KEY) === banner.text); |
There was a problem hiding this comment.
there are a thing here localstroage is shared with api docs but not with sub domain like undici.nodejs.org
There was a problem hiding this comment.
Then I guess a cookie would solve that, right?
|
there are a flash humm not fan of it maybe not display it by default. also what will happen on doc-kit since it's already flash when fetching site.json |
|
To avoid flash, can we dismiss it by default and show only if the value is not set? Screen recording of flash on reload post dismissnodejs-banner-flash-on-reload-post-dismiss.mov |
|
Fixes: #6292 |


Makes the banner close-able.
Note: This just updated

ui-components, and doesn't touch Next.js + cookie handling