materiahq / ngx-monaco-editor

Monaco Editor Library for Angular v6 and above
MIT License
159 stars 35 forks source link

Unable to force layout recalculation of editor inside a tab panel component #40

Closed parky128 closed 3 years ago

parky128 commented 3 years ago

I am struggling with an instance of ngx-monaco-editor inside a primeng tab panel which seems to 'lose' its size calculations when switching to another tab, changing the model value bound to the editor and then switching back to the initial tab again.

https://stackblitz.com/edit/primeng9-tabs-monaco-editor

Steps to replicate using url above:

Before:

enter image description here

After:

enter image description here

Inspecting in the dom, the originally assigned style is still present.

As you can see from the source code in my sample app, I also tried using the editor's layout method in the tab change event to attempt to force a recalculation of the size based on the container but this has made no difference

parky128 commented 3 years ago

@GeoAstronaute I notice you have labelled this as a bug, is there a workaround\solution you can suggest I could try?

jmarc-roy commented 3 years ago

Hi @parky128,

I'm currently working on a new version that will hopefully tackle this issue and will let you know if I have any workaroud in the meantime.

EDIT

Here is a quick workround using your stackblitz example: link. => I pass explicitly the dimension as args to the editor.layout() method (as it's a fixed size in your example)

jmarc-roy commented 3 years ago

Should be fixed in v5.0.0