Skip to content

refactor: simplify SocialShareButton – remove client‑side fallback UI#93

Open
amankv1234 wants to merge 1 commit into
AOSSIE-Org:mainfrom
amankv1234:feature/simplify-social-share
Open

refactor: simplify SocialShareButton – remove client‑side fallback UI#93
amankv1234 wants to merge 1 commit into
AOSSIE-Org:mainfrom
amankv1234:feature/simplify-social-share

Conversation

@amankv1234

@amankv1234 amankv1234 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

📌 Summary

This PR simplifies the SocialShareButton component by removing client‑side error‑fallback UI and unused dependencies. The component now:

  • Imports only useRef and useEffect.
  • Drops the onCopy prop and related fallback logic.
  • Initializes the external widget only when it is present, otherwise logs a warning.
  • Returns a plain <div ref={containerRef}></div> for the widget to mount into.

✅ Why this change?

  • Keeps the client repository minimal and avoids duplicate error handling that belongs in the widget library.
  • Reduces bundle size (no extra icon or state handling).
  • Aligns with maintainer’s request to keep the client side lightweight.

🔧 Issue

Closes #88

📦 Testing

  • Run npm run dev and verify the “Share” button still works on pages that load the widget.
  • When the widget fails to load, the console now shows a warning instead of rendering a fallback button.

Summary by CodeRabbit

  • Bug Fixes
    • Improved social sharing widget initialization and handling when the widget is unavailable.
    • Removed the alternate fallback share action, so the component now relies on the primary sharing widget and shows a warning if it is missing.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

SocialShareButton now initializes the external widget only when window.SocialShareButton is available, logs a warning otherwise, and no longer exposes the onCopy prop or clipboard-copy fallback UI. The effect dependencies were updated to match the remaining inputs.

Changes

Social Share Button Widget Cleanup

Layer / File(s) Summary
Props and imports
src/components/SocialShareButton.jsx
useState and the fallback share icon are removed, and onCopy is no longer part of the component props.
Widget initialization and dependencies
src/components/SocialShareButton.jsx
The effect checks window.SocialShareButton, initializes the widget when available, warns when missing, removes the fallback UI path, and updates the dependency array accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Typescript Lang

Poem

I hopped to the share button, soft and bright,
Then tucked the fallback out of sight.
If widgets load, I tap and cheer,
If not, I warn with rabbit ears.
🐇✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR only updates SocialShareButton.jsx and does not show the required OverviewPage, index.html, or demo cleanup changes for #88. Implement the OverviewPage integration, asset injection, and demo cleanup required by #88, then verify the interactive share button works end to end.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: simplifying SocialShareButton by removing the client-side fallback UI.
Out of Scope Changes check ✅ Passed The changes stay focused on SocialShareButton cleanup and do not introduce obvious unrelated or out-of-scope edits.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added enhancement New feature or request first-time-contributor First time contributor frontend Frontend changes javascript JavaScript/TypeScript changes size/L 201-500 lines changed size/M 51-200 lines changed and removed size/L 201-500 lines changed size/M 51-200 lines changed labels Jun 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/SocialShareButton.jsx`:
- Around line 32-59: The SocialShareButton initialization in useEffect is
relying on a one-time synchronous window.SocialShareButton check, which can run
before the deferred widget script is available. Update the SocialShareButton
component to wait for script availability using a robust readiness strategy such
as DOMContentLoaded or short polling, and only instantiate the widget once
window.SocialShareButton and containerRef.current are both ready. Keep the
existing props passed into new window.SocialShareButton intact, and make sure
the effect can recover if the widget loads after the first render instead of
only logging a warning.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 34d4ab24-93b6-4a8c-861b-02d43e04c243

📥 Commits

Reviewing files that changed from the base of the PR and between c04d3a4 and 2a15b7f.

📒 Files selected for processing (1)
  • src/components/SocialShareButton.jsx

Comment thread src/components/SocialShareButton.jsx

@kpj2006 kpj2006 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@amankv1234 pls share a video with @rahul-vyas-dev

@amankv1234

Copy link
Copy Markdown
Contributor Author

@rahul-vyas-dev ,
check this video and merge it and let me know if there is any problem

https://drive.google.com/file/d/1MI80S5uUce3laciKMA-AW-W1SR4t2_df/view?usp=sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request first-time-contributor First time contributor frontend Frontend changes javascript JavaScript/TypeScript changes size/M 51-200 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants