fix: Refresh code editor when toggling comments tab (#1145)#1633
Open
Kiki-bo-zhang wants to merge 2 commits intoBoostIO:masterfrom
Open
fix: Refresh code editor when toggling comments tab (#1145)#1633Kiki-bo-zhang wants to merge 2 commits intoBoostIO:masterfrom
Kiki-bo-zhang wants to merge 2 commits intoBoostIO:masterfrom
Conversation
Fix code block contrast issues in BoostHub exports: 1. Fix fetchCorrectMdThemeName to return 'default' theme instead of null - When theme was 'default' and appTheme was 'light', it returned null - This caused code blocks to have no styling and poor contrast - Now returns 'default' to ensure proper CodeMirror CSS is loaded 2. Add print styles for better code block readability - Force background color to #f5f5f5 (light gray) - Force text color to BoostIO#333 (dark gray) - Add padding and border-radius for better appearance - Ensure dark theme exports in light mode also have proper contrast Fixes BoostIO#726
Add useEffect to refresh CodeMirror when commentState.mode changes. This fixes the cursor position issue that occurs when opening/closing the comments sidebar, as CodeMirror cannot detect container size changes automatically. Fixes BoostIO#1145
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.
Problem
The cursor position of the editor was broken after opening or closing the comments tab.
Root Cause
CodeMirror emulates cursor position based on its container size, but it cannot detect size changes of the container automatically when the comments sidebar is toggled.
Solution
Added a useEffect hook that calls
editorRef.current.refresh()whenevercommentState.modechanges. This ensures CodeMirror recalculates its layout after the sidebar opens or closes.Changes
src/cloud/components/Editor/index.tsxcommentState.modechangesTesting
Fixes #1145
@BoostIO This PR is for the IssueHunt bounty. Please review when you have time!
IssueHunt Summary
Referenced issues
This pull request has been submitted to: