fix(webapp): clear overlapping timeouts and reset useCopy hook state on value change#4036
Conversation
|
|
Hi @HarshalPatel1972, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Closes #4036
✅ Checklist
Testing
CopyButtonprimitive. Confirmed that making rapid, successive clicks cleanly evicts previous macro-task timer registrations from the event loop using theuseRefpointer.valueprop during an activecopied === truestate window, confirming that the button cleanly reverts back to the copy icon via the newuseEffecthook dependency array tracking layout switches.Changelog
Refactored the core state mechanics of the custom
useCopyhook to handle edge cases and quick-navigation updates seamlessly:useRefpointer container (timeoutRef) to tracking scheduledsetTimeoutidentifiers across rendering cycles.clearTimeoutpass before initializing a new timer instance, resolving visual race conditions from stacked execution intervals.useEffectsynchronization block that automatically unsets thecopiedvisual state whenever the target text prop changes or when the context unmounts.Screenshots
N/A — Structural hook logic adjustment.