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
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
- Refactor
- Removed dynamic window resize listeners for cleaner height tracking in TradingView widget
- Consolidated responsive height styling from nested widget to outer container
- Widget now uses expanded state to toggle between standard and full-viewport height display
- Streamlined dependency management to improve component rendering efficiency
@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: 3d60000f-b9f1-488a-a60a-df61792ee6ed
π₯ Commits
Reviewing files that changed from the base of the PR and between c09e3cf921d71b1dc9a8f412462df31f223006e2 and daa6f1b423ad6c4ac681967958f6aeabc8f5fc7d.
π Files selected for processing (1)
components/TradingViewWidget.tsx
π§ Files skipped from review as they are similar to previous changes (1)
- components/TradingViewWidget.tsx
π Walkthrough
Walkthrough
The PR removes height management from the TradingView hook and component: the hook signature drops the height parameter and stops producing height-based markup; the component moves height styling to its outer container, removes an inner wrapper, and calls the hook with (scriptUrl, widgetConfig) only. Config is serialized once in the hook.
Changes
| Cohort / File(s) | Summary |
|---|---|
Widget component components/TradingViewWidget.tsx |
Removed window resize listener and computed currentHeight; moved height styling to outer container (style={{ height: isExpanded ? '100vh' : height }}); eliminated nested widget wrapper; call to useTradingViewWidget now uses (scriptUrl, widgetConfig) only. |
Hook: useTradingViewWidget hooks/useTradingViewWidget.tsx |
Dropped height parameter from signature; always creates widget container with height: 100%; serialize config once (serializedConfig = JSON.stringify(config)) and use in effect deps [scriptUrl, serializedConfig]; cleanup unchanged. |
Sequence Diagram(s)
(Skipped β changes are refactor/logic simplification, not a new multi-component control flow.)
Estimated code review effort
π― 3 (Moderate) | β±οΈ ~20 minutes
Possibly related PRs
- Open-Dev-Society/OpenStock#4 β Modifies the same TradingViewWidget component and useTradingViewWidget hook; directly touches related code paths.
- Open-Dev-Society/OpenStock#48 β Changes height handling in
useTradingViewWidget.tsx; contrasts with this PR's removal of height logic. - Open-Dev-Society/OpenStock#45 β Previously adjusted passing of computed height into the widget; relevant to the refactor here.
Poem
π° I hopped along the code today,
Moved heights outside where they may stay,
No more inner wrappers to confound,
Widgets snugly fill the ground,
A joyful twitch, the charts all play.
π₯ 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 PR title directly addresses the main issue: preventing chart indicators from disappearing when entering fullscreen mode, which is the core objective of the changeset. |
| Linked Issues check | β Passed | The code changes successfully address issue #49 by preserving the TradingView widget container instead of reinitializing it during fullscreen transitions, which prevents indicator state loss. |
| Out of Scope Changes check | β Passed | All changes are directly related to fixing the chart indicators disappearing issue: removing height tracking from component, simplifying the hook signature, and applying responsive height styling to the container. |
| 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.
Thanks, updated. Fullscreen now uses viewport height, so the widget no longer initializes against a zero-height container.
Closing this in favor of #68 so the contribution is tracked under my main account.
Superseded by #68, which is the same fix reopened from my main account. Please use that PR for review.