OpenStock icon indicating copy to clipboard operation
OpenStock copied to clipboard

Fix chart indicators disappearing in fullscreen

Open softsideof opened this issue 7 months ago β€’ 5 comments

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

softsideof avatar Apr 22 '26 14:04 softsideof

@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.

vercel[bot] avatar Apr 22 '26 14:04 vercel[bot]

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Apr 22 '26 14:04 coderabbitai[bot]

Thanks, updated. Fullscreen now uses viewport height, so the widget no longer initializes against a zero-height container.

softsideof avatar Apr 22 '26 14:04 softsideof

Closing this in favor of #68 so the contribution is tracked under my main account.

keshav-005 avatar Apr 22 '26 14:04 keshav-005

Superseded by #68, which is the same fix reopened from my main account. Please use that PR for review.

keshav-005 avatar Apr 22 '26 14:04 keshav-005