Autoresize with max-height and scrolling

Hey everyone! I’m looking to have the same behaviour shown on this topic here: Code editor with automatic height that has a minimum and maximum height?

But I’m still on Codemirror 5 and couldn’t correctly style it to have scrolling. Essentially I can get the editor to resize automatically but no scrollbar is shown if it hits a maximum size. This is what I have tried:

    .CodeMirror {
      border: 1px solid #eee;
      height: auto;
      max-height: 500px;
      width: auto;
    var editor = CodeMirror.fromTextArea(myTextarea, {
      lineNumbers: false,
      lineWrapping: true,
      viewportMargin: Infinity,

Anyone knows how to enable scrolling with this?

max-height needs to go on CodeMirror-scroll. See the editor on the website font page, which behaves like this too. Also, don’t set viewportMargin to Infinity.

1 Like

Thank you so much, problem solved! :grinning: