Skip to content

fix: replace faulty snackbar with local version#581

Open
ECWireless wants to merge 2 commits intomainfrom
499-copying-poll-contract-address-causes-page-to-crash
Open

fix: replace faulty snackbar with local version#581
ECWireless wants to merge 2 commits intomainfrom
499-copying-poll-contract-address-causes-page-to-crash

Conversation

@ECWireless
Copy link
Collaborator

Description

The copy action was causing the entire page to crash in the CLI dialog within the poll and proposal page. This turned out to be due to the utilization of an imported snackbar that relied on a React 17 method, which does not exist in the React version 19 that we are using. The fix required creating a local snackbar component. This local snackbar was tested locally, and it works.

Some other minor cleanup and a styling fix was also included.

Type of Change

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation update
  • style: Code style/formatting changes (no logic changes)
  • refactor: Code refactoring (no behavior change)
  • perf: Performance improvement
  • test: Adding or updating tests
  • build: Build system or dependency changes
  • ci: CI/CD changes
  • chore: Other changes

Related Issue(s)

Closes: #499

Changes Made

  • Replaced react-copy-to-clipboard with direct copy-to-clipboard usage in the profile, CLI voting dialog, and code block copy actions.

    • Rationale: remove the outdated React wrapper and keep copy behavior explicit and React 19-safe.
  • Added a local SnackbarProvider / useSnackbar and switched the app layout plus migrate pages to use it.

    • Rationale: the design-system snackbar relied on react-transition-group / findDOMNode, which was causing the React 19 crash.
  • Removed react-copy-to-clipboard from package.json and pnpm-lock.yaml.

    • Rationale: dependency cleanup after the copy flow migration.
  • Kept a minimal UI fix in the CLI voting dialog so the proposal ID text no longer runs underneath the copy button.

    • Rationale: fix the overflow issue without changing the overall dialog design.
  • Tightened the copy interactions to only show the copied state after a successful copy and to clean up timers correctly.

    • Rationale: avoid stale UI state and make the behavior consistent.

Testing

  • Tested locally
  • Added/updated tests
  • All tests passing

How to test (optional unless test is not trivial)

  • Since there are no active polls or proposals, the only way to really test is locally removing {proposal.state === "Active" && ( in the TreasuryVotingWidget component, then visiting one of the treasury proposal pages.

Impact / Risk

Risk level: Low

Impacted areas: UI

User impact: page no longer crashes when proposal ID is copied

Rollback plan: PR revert

Screenshots / Recordings

For the minor styling change...

Before:

Screenshot 2026-03-06 at 7 38 53 PM

After:

Screenshot 2026-03-07 at 10 40 18 AM

Additional Notes

NA

Copilot AI review requested due to automatic review settings March 7, 2026 17:52
@ECWireless ECWireless linked an issue Mar 7, 2026 that may be closed by this pull request
@vercel
Copy link
Contributor

vercel bot commented Mar 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer-arbitrum-one Ready Ready Preview, Comment Mar 7, 2026 6:10pm

Request Review

Copy link
Contributor

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 a crash that occurred when copying a poll/proposal contract address in the CLI voting dialog (issue #499). The crash was caused by react-copy-to-clipboard and @livepeer/design-system's SnackbarProvider using React 17-era APIs (findDOMNode via react-transition-group) that are removed in React 19. The fix replaces these with direct copy-to-clipboard usage and a new local SnackbarProvider component.

Changes:

  • Replaced react-copy-to-clipboard wrapper with direct copy-to-clipboard calls in Profile, CliVotingInstructionsDialog, and CodeBlock components, and removed the package dependency.
  • Added a local SnackbarProvider/useSnackbar implementation at components/Snackbar/index.tsx to replace the design-system version that relied on react-transition-group.
  • Applied a minor CSS fix (paddingRight: 48) to the CLI voting dialog so the proposal ID text no longer runs underneath the copy button.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
components/Snackbar/index.tsx New local Snackbar context provider and useSnackbar hook replacing the design-system version
components/CliVotingInstructionsDialog/index.tsx Replaced CopyToClipboard + design-system snackbar with direct copy() + local state; added paddingRight fix
components/CodeBlock/index.tsx Moved copy logic from useEffect to click handler; improved timer cleanup
components/Profile/index.tsx Replaced CopyToClipboard with direct copy() call and explicit button semantics
layouts/main.tsx Switched SnackbarProvider import from design-system to local component
pages/migrate/orchestrator.tsx Switched useSnackbar import from design-system to local component
pages/migrate/delegator/index.tsx Switched useSnackbar import from design-system to local component
pages/migrate/broadcaster.tsx Switched useSnackbar import from design-system to local component
package.json Removed react-copy-to-clipboard dependency
pnpm-lock.yaml Lockfile updates reflecting dependency removal and resolution changes
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

useEffect dependency array only includes stable ref, causing stale code to be copied when children prop changes

Fix on Vercel

Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

useEffect dependency array missing children prop, causing code state to become stale when code content changes

Fix on Vercel

@ECWireless ECWireless requested review from Jipperism and rickstaa March 7, 2026 18:27
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.

Copying poll contract address causes page to crash

2 participants