blueswen / mkdocs-swagger-ui-tag

A MkDocs plugin supports adding Swagger UI to the page.
https://blueswen.github.io/mkdocs-swagger-ui-tag/
MIT License
75 stars 7 forks source link

iframe resizing breaks with instant navigation #9

Closed andreasknoepfle closed 1 year ago

andreasknoepfle commented 1 year ago

When turning on instant loading from mkdocs material and the first page that is visited does not contain any swagger ui tags, the resize handler breaks, since the function is not defined on the parent page.

plugins:
  - swagger-ui-tag

theme:
  name: material
  features:
    - navigation.instant

This is the error that is raised:

Uncaught TypeError: parent.update_swagger_ui_iframe_height is not a function
    at ResizeObserver.<anonymous> (swagger-df07ce82.html:69:14)

It is not a race condition, since the update_swagger_ui_iframe_height is never defined. Once a full page refresh is done, the function is there again, and subsequent pages will have it.

The current workaround for us is to disable navigation.instant, but could this be solved in a better way?

Thanks for creating this 💚

Cheers Andi

blueswen commented 1 year ago

@andreasknoepfle Sorry for the late reply, this has been fixed in the newest version(v0.5.2). Could you check if this does solve your document error?

andreasknoepfle commented 1 year ago

Hello @blueswen

just tested it out again and it works like a charm 💚

Thank you very much