Skip to content

Commit

Permalink
fix: Empty elements taking space in Tall dashboard layout
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed May 8, 2024
1 parent 0920355 commit f482763
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions app/components/chart-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { Checkbox } from "@/components/form";
import { HintYellow } from "@/components/hint";
import { MetadataPanel } from "@/components/metadata-panel";
import { BANNER_MARGIN_TOP } from "@/components/presence";
import VisuallyHidden from "@/components/visually-hidden";
import {
ChartConfig,
DataSource,
Expand Down Expand Up @@ -411,7 +412,7 @@ export const ChartPreviewInner = (props: ChartPreviewInnerProps) => {
) : (
// We need to have a span here to keep the space between the
// title and the chart (subgrid layout)
<span />
<VisuallyHidden />
)}
<Flex sx={{ alignItems: "center", gap: 2 }}>
{!disableMetadataPanel && (
Expand Down Expand Up @@ -443,7 +444,7 @@ export const ChartPreviewInner = (props: ChartPreviewInnerProps) => {
) : (
// We need to have a span here to keep the space between the
// title and the chart (subgrid layout)
<span />
<VisuallyHidden />
)}
{chartConfig.interactiveFiltersConfig?.dataFilters.active ? (
<ChartDataFilters
Expand All @@ -453,7 +454,7 @@ export const ChartPreviewInner = (props: ChartPreviewInnerProps) => {
) : (
// We need to have a span here to keep the space between the
// description and the chart (subgrid layout)
<span />
<VisuallyHidden />
)}
<div
ref={containerRef}
Expand Down
7 changes: 4 additions & 3 deletions app/components/chart-published.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
MetadataPanelStoreContext,
createMetadataPanelStore,
} from "@/components/metadata-panel-store";
import VisuallyHidden from "@/components/visually-hidden";
import {
ChartConfig,
ConfiguratorStatePublished,
Expand Down Expand Up @@ -308,7 +309,7 @@ const ChartPublishedInner = (props: ChartPublishInnerProps) => {
) : (
// We need to have a span here to keep the space between the
// title and the chart (subgrid layout)
<span />
<VisuallyHidden />
)}
<MetadataPanel
dataSource={dataSource}
Expand All @@ -322,7 +323,7 @@ const ChartPublishedInner = (props: ChartPublishInnerProps) => {
) : (
// We need to have a span here to keep the space between the
// title and the chart (subgrid layout)
<span />
<VisuallyHidden />
)}
{chartConfig.interactiveFiltersConfig?.dataFilters.active ? (
<ChartDataFilters
Expand All @@ -332,7 +333,7 @@ const ChartPublishedInner = (props: ChartPublishInnerProps) => {
) : (
// We need to have a span here to keep the space between the
// description and the chart (subgrid layout)
<span />
<VisuallyHidden />
)}
<div
ref={containerRef}
Expand Down
1 change: 1 addition & 0 deletions app/components/chart-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const useChartStyles = makeStyles<Theme>((theme) => ({
display: "grid",
gridTemplateRows: "subgrid",
gridRow: shouldShowDebugPanel() ? "span 7" : "span 6",
rowGap: 0,
padding: theme.spacing(6),
backgroundColor: theme.palette.background.paper,
border: "1px solid",
Expand Down
2 changes: 1 addition & 1 deletion app/components/visually-hidden.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box } from "@mui/material";
import { visuallyHidden } from "@mui/utils";

const VisuallyHidden = ({ children }: { children: React.ReactNode }) => {
const VisuallyHidden = ({ children }: { children?: React.ReactNode }) => {
// @ts-ignore - I do not know why CSSProperties do not go directly into sx. It works.
return <Box sx={visuallyHidden}>{children}</Box>;
};
Expand Down

0 comments on commit f482763

Please sign in to comment.