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] Styling broken for Shadow DOM #3017

Closed
2 tasks
philkunz opened this issue Mar 10, 2022 · 7 comments
Closed
2 tasks

[Bug] Styling broken for Shadow DOM #3017

philkunz opened this issue Mar 10, 2022 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-shadow-dom

Comments

@philkunz
Copy link

philkunz commented Mar 10, 2022

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Code

const template = document.createElement('template');
template.innerHTML = `
<style>
    #innercontainer {
        height: 100%;
    }
</style>
<div id="innercontainer">
  
</div>`;

class MonacoWC extends HTMLElement {
    constructor() {
        super();
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.appendChild(template.content.cloneNode(true));
    }

    connectedCallback() {
        const innercontainer = this.shadowRoot.getElementById('innercontainer');
        monaco.editor.create(innercontainer, {
            value: "function hello() {\n\talert('Hello world!');\n}",
            language: 'javascript'
        });
    }

    render() {

    }
}
window.customElements.define('monaco-wc', MonacoWC);
const container = document.getElementById('container');
const wcEditor = document.createElement('monaco-wc');
container.append(wcEditor);

Actual Behavior

editor is loaded, however styling is off. lines change order upon scrolling

Expected Behavior

editor should load normally, woth scrolling not affecting lines order.

Additional Context

@hediet
Copy link
Member

hediet commented Mar 11, 2022

I marked this as question as we don't have the resources to investigate issues in third party source code.
Please provide a minimal example that is reproducible in the monaco editor playground.

@philkunz
Copy link
Author

@hediet Please see the updated issue. I created a Playground example that shows the issue. Just replace the Javascript in the HelloWorld example. Thank you!

@hediet
Copy link
Member

hediet commented Mar 14, 2022

Thanks for the example! I can reproduce, it looks completely broken.

@hediet hediet added bug Issue identified by VS Code Team member as probable bug editor-shadow-dom and removed question labels Mar 14, 2022
@cameronbraid
Copy link

Has anyone discovered a workaround ?

@cameronbraid
Copy link

I found a workaround : include the monaco-editor/min/vs/editor/editor.main.css styles in the shadow dom

@philkunz
Copy link
Author

@cameronbraid nice, I confirm that this works.
Also I created a simple to use lit based web component, that works out of the box: https://gitlab.com/designestate/dees-editor

Simply put the component anywhere where you want to have a monaco editor.
The API will get more features over the next few days.

@hediet
Copy link
Member

hediet commented Mar 10, 2023

Check out this example.

You have to include the CSS in the web component.

@hediet hediet closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-shadow-dom
Projects
None yet
Development

No branches or pull requests

4 participants