feat(react): notification action buttons#74
Open
soufian3hm wants to merge 2 commits into
Open
Conversation
Frontend slice. WellKnownPayload gains primary_action/secondary_action
({ label, url? }, exported as PayloadAction). The default item renders
them as buttons below the content, with onPrimaryActionClick/
onSecondaryActionClick props and a renderActions escape hatch. URLs
reuse a shared safe-navigation helper (followActionUrl), and the item
divider moves to the row so the buttons sit inside it.
Closes dodopayments#35
Comment on lines
+307
to
+309
| if (typeof label === 'string' && label.length > 0) { | ||
| return label; | ||
| } |
There was a problem hiding this comment.
Whitespace Labels Stay Clickable
A payload with { label: " " } passes this check, so the default row renders a blank CTA that can still run onAction and follow its URL. The payload contract says blank labels render nothing, so this malformed action becomes an invisible clickable control.
Suggested change
| if (typeof label === 'string' && label.length > 0) { | |
| return label; | |
| } | |
| if (typeof label === 'string' && label.trim().length > 0) { | |
| return label; | |
| } |
Context Used: CLAUDE.md (source)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #35.
Frontend-only first slice of notification action buttons.
What
@chimely/client:WellKnownPayloadgains optionalprimary_action/secondary_action({ label: string; url?: string }), exported asPayloadAction. Additive, per the payload contract.@chimely/react: the default item renders the actions as buttons below its content. NewonPrimaryActionClick/onSecondaryActionClickprops (returnfalseto veto navigation) and arenderActionsescape hatch for custom UI.action_urlvia a new sharedfollowActionUrlhelper: same-origin ->routerPush(when provided), otherwise a full assign;javascript:/data:/ custom schemes are refused. The item click was refactored onto the same helper..chimely-itemto the row via.chimely-list-row:has(> .chimely-item)-- the CTAs sit inside the item, above the line. CustomrenderItemrows are unaffected (the:hasscope).Deferred (as the issue frames it)
completePrimary/revertPrimary) -- the issue says defer until someone asks. No server change here.InboxLocalizationstrings.Verification
biome,pnpm --filter "./packages/*" build, typecheck, and vitest are all green:@chimely/client54 +@chimely/react111 tests, including 6 new ones (render + follow URL, no action bar without actions, same-origin routerPush,onPrimaryActionClickveto,javascript:refused,renderActionsoverride). A minor changeset covers both packages.