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

CodeMirrorMerge - Gutter size ingreses when updating #520

Closed
guillermoamaral opened this issue Jun 6, 2023 · 3 comments
Closed

CodeMirrorMerge - Gutter size ingreses when updating #520

guillermoamaral opened this issue Jun 6, 2023 · 3 comments
Labels

Comments

@guillermoamaral
Copy link

For some reason that I cannot figure out, updating both original and modified values makes gutter margin to increase.

https://codesandbox.io/s/fast-shadow-8v936f?file=/src/App.js

Am I doing someting wrong?

jaywcjlove added a commit that referenced this issue Jun 7, 2023
jaywcjlove added a commit that referenced this issue Jun 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
github-actions bot pushed a commit that referenced this issue Jun 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@jaywcjlove
Copy link
Member

@guillermoamaral Upgrade v4.21.2

import React, { useState } from "react";
import CodeMirrorMerge from "react-codemirror-merge";
import { EditorView } from "@codemirror/view";

const Original = CodeMirrorMerge.Original;
const Modified = CodeMirrorMerge.Modified;

function randomText(size) {
  let letters = `abcdefghyjklmnopqrstuvwxyz`;
  let text = "";
  for (let i = 0; i < size; i++) {
    text = text + letters[Math.floor(Math.random() * letters.length)];
  }
  return text;
}

export default function App() {
  const [value, setValue] = useState("abc");
  const [valueModified, setValueModified] = useState("ab");
  return (
    <div>
      <button
        onClick={() => {
          setValue(randomText(10));
          setValueModified(randomText(10));
        }}
      >
        Update
      </button>
      <CodeMirrorMerge orientation="a-b" gutter={false}>
        <Original
          extensions={[EditorView.lineWrapping]}
          onChange={(value) => {
            setValue(value);
          }}
          value={value}
        />
        <Modified
          extensions={[EditorView.lineWrapping]}
          onChange={(value) => {
            setValueModified(value);
          }}
          value={valueModified}
        />
      </CodeMirrorMerge>
    </div>
  );
}

@jaywcjlove jaywcjlove added the demo label Jun 7, 2023
@jaywcjlove
Copy link
Member

https://codesandbox.io/embed/bitter-dream-2x1byh?fontsize=14&hidenavigation=1&theme=dark

@guillermoamaral
Copy link
Author

Many thanks sr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants