fix: replace faulty snackbar with local version#581
Open
ECWireless wants to merge 2 commits intomainfrom
Open
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
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-clipboardwrapper with directcopy-to-clipboardcalls in Profile, CliVotingInstructionsDialog, and CodeBlock components, and removed the package dependency. - Added a local
SnackbarProvider/useSnackbarimplementation atcomponents/Snackbar/index.tsxto replace the design-system version that relied onreact-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.
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.
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
Related Issue(s)
Closes: #499
Changes Made
Replaced
react-copy-to-clipboardwith directcopy-to-clipboardusage in the profile, CLI voting dialog, and code block copy actions.Added a local
SnackbarProvider/useSnackbarand switched the app layout plus migrate pages to use it.react-transition-group/findDOMNode, which was causing the React 19 crash.Removed
react-copy-to-clipboardfrompackage.jsonandpnpm-lock.yaml.Kept a minimal UI fix in the CLI voting dialog so the proposal ID text no longer runs underneath the copy button.
Tightened the copy interactions to only show the copied state after a successful copy and to clean up timers correctly.
Testing
How to test (optional unless test is not trivial)
{proposal.state === "Active" && (in theTreasuryVotingWidgetcomponent, 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:
After:
Additional Notes
NA