Skip to content
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

Bug: Cursor Issue #659

Open
KrishT0 opened this issue Dec 23, 2024 · 0 comments
Open

Bug: Cursor Issue #659

KrishT0 opened this issue Dec 23, 2024 · 0 comments

Comments

@KrishT0
Copy link

KrishT0 commented Dec 23, 2024

When I try to click on Monaco editor after some width, the cursor doesn't go. Also, it feels weird when writing from that point. My screen is at zoom level 90%, but this issue gets fixed when I zoom the screen for 100% or more.

Demo

2024-12-23.14-53-57.mp4

Code :

import {
  useState,
  useEffect,
  forwardRef,
  useRef,
  useImperativeHandle,
} from "react";
import Editor from "@monaco-editor/react";
import { useMediaQuery } from "@/hooks/use-media-query";

const MonacoEditorComponent = forwardRef(({ language, defaultCode }, ref) => {
  const [code, setCode] = useState(defaultCode);
  const editorRef = useRef();
  const isSmallScreen = useMediaQuery("(min-width: 500px)");

  useEffect(() => {
    setCode(defaultCode);
  }, [defaultCode]);

  const editorOptions = {
    fontFamily: "JetBrains Mono",
    fontSize: 13,
    fontWeight: 700,
    wordWrap: "on",
    minimap: {
      enabled: isSmallScreen ? true : false,
    },
  };

  const onMount = (editor) => {
    editorRef.current = editor;
    editorRef.current.focus();
  };

  useImperativeHandle(ref, () => ({
    getValue: () => editorRef.current.getValue(),
  }));

  return (
    <Editor
      height="100%"
      defaultLanguage={language}
      language={language}
      theme="vs-dark"
      onMount={onMount}
      value={code}
      onChange={(value) => setCode(value)}
      options={editorOptions}
    />
  );
});

export default MonacoEditorComponent;
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

No branches or pull requests

1 participant