Skip to content

Bug - [CodeEditor] - Resize observer does not properly shrink CodeEditor #11531

@logonoff

Description

@logonoff

Describe the problem
A clear and concise description of the problem. Which components are affected?

How do you reproduce the problem?
Provide steps to reproduce. A codesandbox demonstrating the problem is appreciated.

have a CodeEditor with width 100% and resize the viewport a few times

Expected behavior
A clear and concise description of the expected behavior.

the codeeditor shrinks

Is this issue blocking you?
List the workaround if there is one.

Yes. Workaround is to add this to my CodeEditor, where monacoRef is the internal monaco object:

  const handleResize = React.useCallback(() => {
      monacoRef?.editor?.getEditors()?.forEach((editor) => {
        editor.layout({ width: 0, height: 0 })
        editor.layout();
      });
  }, [monacoRef]);

  React.useEffect(() => {
    const observer = getResizeObserver(undefined, handleResize, true);

    return () => {
      observer();
    };
  }, [handleResize]);

Screenshots
If applicable, add screenshots to help explain the issue.

Screencast.From.2025-02-13.17-36-34.mp4

What is your environment?

  • OS: Fedora 41
  • Browser: Firefox 135.0

What is your product and what release date are you targeting?
OCP 4.19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions