Skip to content

Fix: Ensure Custom Themes Are Applied in Monaco Editor Initialization#198

Closed
sancheet230 wants to merge 2 commits intoaccordproject:mainfrom
sancheet230:main
Closed

Fix: Ensure Custom Themes Are Applied in Monaco Editor Initialization#198
sancheet230 wants to merge 2 commits intoaccordproject:mainfrom
sancheet230:main

Conversation

@sancheet230
Copy link
Contributor

@sancheet230 sancheet230 commented Mar 8, 2025

Closes #197

This PR resolves the issue where custom themes were not being applied correctly in the Monaco Editor. The primary change involves defining the custom themes using the beforeMount prop to ensure they are set prior to the editor's initialization

Changes

  1. Theme Definition Before Editor Mount: Utilized the beforeMount prop to define custom themes before the Monaco Editor initializes, ensuring the themes are applied correctly.
  2. Direct Use of Editor Component: Replaced the lazy-loaded MonacoEditor with the direct use of the Editor component from @monaco-editor/react to simplify the code and ensure proper theme application.
  3. Memoization of Functions and Variables: Applied useCallback and useMemo hooks to memoize functions and variables, preventing unnecessary re-renders and function recreations.

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

Signed-off-by: sancheet230 <sancheet.p24@medhaviskillsuniversity.edu.in>
@sancheet230 sancheet230 requested a review from a team as a code owner March 8, 2025 05:01
@netlify
Copy link

netlify bot commented Mar 8, 2025

Deploy Preview for ap-template-playground ready!

Name Link
🔨 Latest commit 41d5e42
🔍 Latest deploy log https://app.netlify.com/sites/ap-template-playground/deploys/67d0100e8d4cd7000875535a
😎 Deploy Preview https://deploy-preview-198--ap-template-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sancheet230
Copy link
Contributor Author

@DianaLease Can you review this PR and attached issue whenever you are free

Copy link
Member

@DianaLease DianaLease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot reproduce your original issue and your PR changes break the dark mode toggle.

@DianaLease DianaLease closed this Mar 14, 2025
@sancheet230
Copy link
Contributor Author

@DianaLease @nitro56565 have already solved the main theme issue for monaco editor with #139 But I purposed some new performance and readability modifications like Performance Improvement: Using useMemo and useCallback can improve performance by memoizing values and functions preventing unnecessary re-renders
Code Clarity: The refactoring makes the code cleaner and easier to understand, especially the handling of themes and options
Type Safety: Changing the onChange prop to a mandatory function improves type safety and ensures that onChange is always provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom Themes Not Applied When Defined After Monaco Editor Instantiation

2 participants