Wednesday 11 November 2020

ngx-monaco-editor - unable to force layout when container changes (using tab panel)

I am struggling with an instance of an 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:

  • The 'Editor' tab will be initially selected
  • Select 'Tab 2'
  • Click the 'change code' button
  • Change back to the 'Editor' tab and now see that the editor has shrunk in size

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

Interestingly if I resize the window this does seem to trigger the editor component to resize again correctly.



from ngx-monaco-editor - unable to force layout when container changes (using tab panel)

No comments:

Post a Comment