diff --git a/.changeset/afraid-poets-thank.md b/.changeset/afraid-poets-thank.md new file mode 100644 index 0000000000..b234e2e2c1 --- /dev/null +++ b/.changeset/afraid-poets-thank.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog': patch +--- + +Fix card scrolling behaviour diff --git a/plugins/catalog/src/alpha/DefaultEntityContentLayout.tsx b/plugins/catalog/src/alpha/DefaultEntityContentLayout.tsx index 21276f424a..3188b98437 100644 --- a/plugins/catalog/src/alpha/DefaultEntityContentLayout.tsx +++ b/plugins/catalog/src/alpha/DefaultEntityContentLayout.tsx @@ -41,7 +41,7 @@ const useStyles = makeStyles< flexFlow: 'column nowrap', gap: theme.spacing(3), }, - contentArea: { + mainContent: { display: 'flex', flexFlow: 'column', gap: theme.spacing(3), @@ -51,9 +51,13 @@ const useStyles = makeStyles< infoArea: { display: 'flex', flexFlow: 'column nowrap', - alignItems: 'stretch', + alignItems: 'flex-start', gap: theme.spacing(3), minWidth: 0, + '& > *': { + flexShrink: 0, + flexGrow: 0, + }, }, summaryArea: { minWidth: 0, @@ -65,10 +69,17 @@ const useStyles = makeStyles< marginLeft: theme.spacing(3), }, }, + contentArea: { + display: 'flex', + flexFlow: 'column', + gap: theme.spacing(3), + alignItems: 'stretch', + minWidth: 0, + }, [theme.breakpoints.up('md')]: { root: { display: 'grid', - gap: 0, + gap: theme.spacing(3), gridTemplateAreas: ({ summaryCards }) => ` "${summaryCards ? 'summary' : 'content'} info" "content info" @@ -76,11 +87,8 @@ const useStyles = makeStyles< gridTemplateColumns: ({ infoCards }) => (infoCards ? '2fr 1fr' : '1fr'), alignItems: 'start', }, - infoArea: { - gridArea: 'info', - position: 'sticky', - top: theme.spacing(3), - marginLeft: theme.spacing(3), + mainContent: { + display: 'contents', }, contentArea: { gridArea: 'content', @@ -89,6 +97,25 @@ const useStyles = makeStyles< gridArea: 'summary', marginBottom: theme.spacing(3), }, + infoArea: { + gridArea: 'info', + position: 'sticky', + top: theme.spacing(3), + // this is a little unfortunate, but it's required to make the info cards scrollable + // in a fixed container of the full height when it's stuck. + // 100% doesn't work as that's the height of the entire layout, which is what powers the card scrolling. + maxHeight: '100vh', + overflowY: 'auto', + alignSelf: 'start', + alignItems: 'stretch', + // Hide the scrollbar for the inner info cards + // kind of an accessibility nightmare, but we see. + scrollbarWidth: 'none', + msOverflowStyle: 'none', + '&::-webkit-scrollbar': { + display: 'none', + }, + }, }, })); @@ -144,20 +171,22 @@ export function DefaultEntityContentLayout(props: EntityContentLayoutProps) { {infoCards.map(card => card.element)} ) : null} - {summaryCards.length > 0 ? ( -
- - {summaryCards.map(card => ( -
{card.element}
- ))} -
-
- ) : null} - {contentCards.length > 0 ? ( -
- {contentCards.map(card => card.element)} -
- ) : null} +
+ {summaryCards.length > 0 ? ( +
+ + {summaryCards.map(card => ( +
{card.element}
+ ))} +
+
+ ) : null} + {contentCards.length > 0 ? ( +
+ {contentCards.map(card => card.element)} +
+ ) : null} +
);