Fix chart indicators disappearing in fullscreen
Summary
- keep TradingView chart widgets mounted when toggling fullscreen
- resize the existing widget container instead of reinitializing the embed, which preserves indicator state
- use viewport height in fullscreen mode so the widget never initializes against a zero-height container
Test plan
- npx eslint components/TradingViewWidget.tsx hooks/useTradingViewWidget.tsx
- npx tsc --noEmit (currently fails on pre-existing errors in lib/inngest/functions.ts; not caused by this change)
Fixes Open-Dev-Society/OpenStock#49
Summary by CodeRabbit
-
Bug Fixes
- Fixed TradingView widget height rendering to properly display at full viewport dimensions when expanded.
-
Refactor
- Simplified widget configuration and initialization by removing unnecessary resize event listeners and redundant state management, improving code efficiency and performance.
@keshav-005 is attempting to deploy a commit to the ravixalgorithm's projects Team on Vercel.
A member of the Team first needs to authorize it.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 34828ec0-9a19-4834-842f-c5b383bf20ca
📥 Commits
Reviewing files that changed from the base of the PR and between fe59884827e7cdc0080e342b885a3d8f1d3a6878 and daa6f1b423ad6c4ac681967958f6aeabc8f5fc7d.
📒 Files selected for processing (2)
components/TradingViewWidget.tsxhooks/useTradingViewWidget.tsx
📝 Walkthrough
Walkthrough
Simplifies TradingViewWidget height handling by removing dynamic height state management and parameter passing to the hook. The widget now uses viewport-based sizing (100vh when expanded) instead of computed heights, addressing the issue of indicators disappearing during full-screen transitions.
Changes
| Cohort / File(s) | Summary |
|---|---|
Height Parameter Removal components/TradingViewWidget.tsx, hooks/useTradingViewWidget.tsx |
Removed dynamic height parameter and state logic from both component and hook. Component now controls sizing with 100vh for expanded state and height prop for compact state. Hook signature simplified to accept only scriptUrl and config. Eliminated resize listener and intermediate height computation. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
- #48: Both PRs modify
hooks/useTradingViewWidget.tsxand directly change its height-handling logic and function signature. - #45: Both PRs modify
TradingViewWidget.tsxanduseTradingViewWidget.tsxheight/resize handling, impacting the same code paths.
Poem
🐰 When widgets grew too tall and indicators fled,
A simpler path emerged instead—
One hundred viewport heights so clear,
No dancing heights that disappear! ✨
Full-screen harmony is finally here!
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title directly addresses the main change: fixing chart indicators disappearing in fullscreen by preserving widget state during fullscreen toggle. |
| Linked Issues check | ✅ Passed | The pull request addresses the core objective from issue #49 by preserving chart indicators when toggling fullscreen through widget lifecycle management changes. |
| Out of Scope Changes check | ✅ Passed | All changes are directly related to fixing the indicator loss issue: modifying TradingViewWidget and useTradingViewWidget to preserve state and handle fullscreen sizing appropriately. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ 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.
Comment @coderabbitai help to get the list of available commands and usage tips.