rapi-doc / RapiDoc

RapiDoc -WebComponent for OpenAPI Spec
https://rapidocweb.com
MIT License
1.71k stars 285 forks source link

Scroll doesn't work when rendered from react #221

Closed p10ns11y closed 4 years ago

p10ns11y commented 4 years ago

I tried mounting the rapid-doc webcomponent as react component. It renders the layout and content but not able to scroll properly. It jumps back to top all the time when I try to scroll.

Here is the code sandbox: https://codesandbox.io/s/green-rain-74g85?file=/src/App.js

mrin9 commented 4 years ago

if you are using render-style='read' then ensure that the component gets a proper height either by specifying directly on to the component's style or by way of inheriting it from the parent component. This is needed coz, as you scroll the main content, the left nav-bar would adjust its scroll position based on it.

https://codesandbox.io/s/upbeat-sea-4tfo7?file=/src/App.js

import React from "react";
import "rapidoc";
import "./styles.css";

export default function App() {
  return (
    <rapi-doc
      style={{height:"100vh", width:"100%"}}
      spec-url="https://petstore.swagger.io/v2/swagger.json"
      render-style = "read"
    ></rapi-doc>
  );
}