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

Pressing the tab key on a readonly textarea causes a tab in the value #152

Open
SangJunBak opened this issue Jun 21, 2023 · 1 comment
Open

Comments

@SangJunBak
Copy link

No description provided.

jaywcjlove added a commit that referenced this issue Jun 23, 2023
jaywcjlove added a commit that referenced this issue Jun 23, 2023
github-actions bot pushed a commit that referenced this issue Jun 23, 2023
@jaywcjlove
Copy link
Member

@SangJunBak Upgrade v2.1.7 https://codesandbox.io/embed/wonderful-night-4m86j4?fontsize=14&hidenavigation=1&theme=dark

import React, { useEffect } from "react";
import CodeEditor, { SelectionText } from "@uiw/react-textarea-code-editor";
import "./styles.css";

export default function App() {
  const textRef = React.useRef();
  const [code, setCode] = React.useState(
    `function add(a, b) {\n  return a + b;\n}`
  );
  useEffect(() => {
    if (textRef.current) {
      const obj = new SelectionText(textRef.current);
      console.log("obj:", obj);
    }
  }, []);
  return (
    <>
      <div>
        <h3>Auto</h3>
        <CodeEditor
          value={code}
          ref={textRef}
          language="js"
          placeholder="Please enter JS code."
          onChange={(evn) => setCode(evn.target.value)}
          padding={15}
          readOnly
          style={{
            fontFamily:
              "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace",
            fontSize: 12
          }}
        />
      </div>
    </>
  );
}

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

2 participants