- 
                Notifications
    You must be signed in to change notification settings 
- Fork 71
LG-5446: CodeEditor QA Fixes #3261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| 🦋 Changeset detectedLatest commit: abf02e4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
 Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR | 
| Size Change: +1.79 kB (+0.11%) Total Size: 1.62 MB 
 ℹ️ View Unchanged
 | 
…o view after actions
…ent unstyled render
…r rendering control and optimize extension return with useMemo for performance
…hanced testing capabilities
…styles and package configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses multiple QA bugs to bring the CodeEditor component to a V1 state, focusing on visual refinements, interaction improvements, and test infrastructure enhancements. The changes fix issues discovered during QA testing including layout problems, theme handling, and state management.
Key Changes:
- Refactored editor initialization to prevent content loss when props change (dark mode switching no longer overwrites code)
- Enhanced Panel component to respect width constraints and properly disable undo/redo based on available actions
- Improved test infrastructure by introducing synchronous testing with preloaded modules, eliminating async loading delays
Reviewed Changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description | 
|---|---|
| packages/code-editor/src/CodeEditor/CodeEditor.tsx | Split editor initialization and extension configuration into separate effects to prevent re-initialization on prop changes | 
| packages/code-editor/src/Panel/Panel.tsx | Added context-aware darkMode and baseFontSize handling, disabled undo/redo when unavailable | 
| packages/code-editor/src/CodeEditor/CodeEditor.styles.ts | Added dynamic height calculation for loading state based on content lines | 
| packages/code-editor/src/testing/preLoadedModules.ts | Created centralized module preloading for synchronous test execution | 
| packages/code-editor/src/SearchPanel/SearchPanel.spec.tsx | Extracted search functionality tests into dedicated spec file | 
| packages/code-editor/src/CodeEditor/CodeEditor.ImperativeHandle.spec.tsx | Extracted imperative handle tests into dedicated spec file | 
| packages/code-editor/src/CodeEditor/hooks/extensions/useThemeExtension.ts | Exported constants for height calculations and adjusted gutter padding | 
| packages/code-editor/src/ContextMenu/ContextMenu.tsx | Added mousedown prevention to preserve selection when opening context menu | 
| packages/code-editor/src/CodeEditorCopyButton/CodeEditorCopyButton.styles.ts | Fixed checkmark icon color in copied state for both themes | 
        
          
                packages/code-editor/src/CodeEditor/hooks/extensions/useTooltipExtension.ts
          
            Show resolved
            Hide resolved
        
              
          
                packages/code-editor/src/CodeEditor/hooks/extensions/useCodeFoldingExtension.tsx
              
                Outdated
          
            Show resolved
            Hide resolved
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a chunky PR but I'll approve it this time
        
          
                packages/code-editor/src/CodeEditor/hooks/extensions/useReadOnlyExtension.spec.ts
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                packages/code-editor/src/CodeEditor/hooks/extensions/useCodeFoldingExtension.tsx
          
            Show resolved
            Hide resolved
        
              
          
                packages/code-editor/src/CodeEditor/hooks/extensions/useThemeExtension.ts
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | <CodeEditor.Panel | ||
| title="Test Panel" | ||
| innerContent={ | ||
| <div data-testid={PANEL_TEST_ID}>Test Panel Content</div> | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: don't we have test utils to get the panel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, will update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Since the editor is created in a separate effect without extensions, it is created before the extensions | ||
| * are applied. This prevents a blink of an unstyled editor. | ||
| */ | ||
| const rafId = requestAnimationFrame(() => { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the extensions always be rendered after the next frame?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. We have an extensionsInitialized prop that technically isn't set until after the extensions are dispatched, and this prevents showing the editor until true. My original thought was that this is all that would be needed, but it didn't work. So the theory at least is that there must be a small race condition and this prevents it. I'm not sure of a better way to handle it, but would be open to ideas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original thought was that this is all that would be needed, but it didn't work.
So you were trying to set setExtensionsInitialized without requestAnimationFrame but that wasn't working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, you still saw just a blink of non-styled content
| justify="middle" | ||
| trigger={ | ||
| <IconButton | ||
| darkMode={theme === 'dark'} | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Shouldn't this component use the darkMode value from tooltip?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should open a ticket to investigate this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I don't think this should block this PR but I can create that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Coverage after merging LG-5446/ce-qa into main will be 
 Coverage Report
 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||



✍️ Proposed changes
This PR fixes a number of bugs and missed features that were found in QA.
Bugs that were found in QA can be found in the CodeEditor QA Issue Log. This PR fixes the following:
Additional drive-by fixes:
CodeEditor.specby:CodeEditor.specfor core functionalityCodeEditor.ImperativeHandle.specfor testing the imperative handle functionalitySearchPanel.specfor testing search functionalitypreloadedModules. This makes the tests more straight forward to reason with since it removes any loading🎟️ Jira ticket: LG-5446
✅ Checklist
pnpm changesetand documented my changes🧪 How to test changes