Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/__stories__/JsonSchemaViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ storiesOf('JsonSchemaViewer', module)
</Box>
</InvertTheme>
);
});
})
.add('maxHeight', () => <JsonSchemaViewer schema={schema as JSONSchema4} maxHeight={number('maxHeight', 500)} />);

storiesOf('JsonSchemaViewer/combiners', module)
.addDecorator(withKnobs)
Expand Down
3 changes: 1 addition & 2 deletions src/__stories__/_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
@import '~@stoplight/mosaic/themes/default.css';

.JsonSchemaViewer {
margin: auto;
margin: 20px auto;
width: 100%;
padding: 20px;
max-width: 800px;
}
2 changes: 1 addition & 1 deletion src/hooks/useIsOnScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function getScrollParent(node: HTMLElement | null): HTMLElement | typeof window
return null;
}

if (node.scrollHeight > node.clientHeight) {
if (node.scrollHeight > node.clientHeight && node.clientHeight > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ui-kit scroll container wraps things with a 0 height 0 width "scrollable" container (freaking weird lol), which breaks this behavior. Added this extra check to ignore 0 height parent containers, which fixes the issue (I yalc'd and confirmed this in platform).

Screen Shot 2021-12-02 at 4 42 23 PM

return node.tagName === 'HTML' ? window : node;
} else {
return getScrollParent(node.parentElement);
Expand Down