Forward teaser.dismissible through FloatBubble/useFloatBubble#74
Merged
Conversation
Contributor
📦 Snapshot ReleasePublished snapshot packages for this PR: pnpm add @perspective-ai/sdk@1.15.1-pr-74-20260713201345
pnpm add @perspective-ai/sdk-react@1.15.1-pr-74-20260713201345Or use the npm tag (always points to the latest snapshot from this PR): pnpm add @perspective-ai/sdk@pr-74
pnpm add @perspective-ai/sdk-react@pr-74 |
There was a problem hiding this comment.
Pull request overview
This PR fixes the React wrapper (@perspective-ai/sdk-react) not forwarding the core SDK’s teaser.dismissible option, ensuring teaser={{ dismissible: false }} correctly hides the float teaser × dismiss button when using useFloatBubble / FloatBubble.
Changes:
- Forward
teaser.dismissiblethroughuseFloatBubbleby stabilizing it alongside the other teaser primitive fields and adding it to the memo dependencies. - Add a hook test verifying all teaser fields (
enabled,delay,sound,dismissible) are passed tocreateFloatBubble. - Add a changeset to publish a patch release of
@perspective-ai/sdk-react.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/sdk-react/src/hooks/useFloatBubble.ts | Adds teaser.dismissible to the stabilized teaser config passed into createFloatBubble. |
| packages/sdk-react/src/hooks/useFloatBubble.test.ts | Adds a regression test asserting dismissible is forwarded to the core SDK. |
| .changeset/float-teaser-dismissible-react.md | Declares a patch bump and documents the forwarding fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The 1.15.0 teaser `dismissible` option was added to the core SDK but the
React wrapper never forwarded it. useFloatBubble stabilizes the teaser prop
on its primitive fields and only carried `enabled`, `delay`, and `sound`,
so `dismissible` was silently dropped — `teaser={{ dismissible: false }}`
had no effect and the × dismiss button always rendered.
Add `dismissible` to the stabilized teaser object (and its useMemo deps) so
it reaches createFloatBubble, plus a test asserting all teaser fields are
forwarded.
Also audited the other teaser surfaces to confirm none share the bug: the
vanilla createFloatBubble config and the CDN data-perspective-teaser*
attributes both forward dismissible already (core resolveTeaserConfig
spreads all fields; the data-attribute parser reads all four), each covered
by existing tests. Corrected the EmbedConfig.teaser JSDoc, which listed only
enabled/delay/sound, to include dismissible. Adds a changeset patching both
packages.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172vANJgSbNmv6nnQUErgU2
17ea7b6 to
86d1ddb
Compare
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.
Problem
1.15.0added theteaser.dismissibleoption (the × button that lets a visitor dismiss the float teaser without opening the chat). The core@perspective-ai/sdkrenders and honors it, but the React wrapper never forwards it, soteaser={{ dismissible: false }}has no effect when using@perspective-ai/sdk-react— the × button always renders.The cause is in
useFloatBubble, which stabilizes the teaser prop on its primitive fields (to avoid remounting the bubble on every parent render) and only carried three of them:dismissiblewas never destructured, so it never reachedcreateFloatBubble.This surfaced downstream in the demos site, where
&teaser.dismissible=falseon the float/chat page had no effect despite the param being parsed and passed correctly.Fix
packages/sdk-react/src/hooks/useFloatBubble.ts— destructureteaser?.dismissible, add it to the stabilized teaser object, and include it in theuseMemodependency array.packages/sdk-react/src/hooks/useFloatBubble.test.ts— new test asserting all four teaser fields (enabled,delay,sound,dismissible) are forwarded tocreateFloatBubble.Audit of the other teaser surfaces
Confirmed the React hook was the only surface dropping the field. Every other path already forwards
dismissibleand is test-covered:createFloatBubble({ teaser })resolveTeaserConfigspreads all fields)float.test.tsdata-perspective-teaser-dismissiblebrowser.test.ts<FloatBubble>/useFloatBubblepackages/sdk/src/types.ts— the only remaining inaccuracy was theEmbedConfig.teaserJSDoc, which listedenabled/delay/soundbut notdismissible; corrected so the documented API matches.Changeset
.changeset/float-teaser-dismissible-react.md—patchbump for both@perspective-ai/sdk-reactand@perspective-ai/sdk(the packages arefixed-linked).Verification
@perspective-ai/sdk—pnpm typecheckclean, 455 tests pass.@perspective-ai/sdk-react—pnpm typecheckclean, 91 tests pass (including the new one).pnpm buildsucceeds anddismissiblenow appears in the compileddist/index.js.🤖 Generated with Claude Code