diff --git a/packages/widgets/src/calendar/calendar-event-list.tsx b/packages/widgets/src/calendar/calendar-event-list.tsx index 992da9d71..8b321d367 100644 --- a/packages/widgets/src/calendar/calendar-event-list.tsx +++ b/packages/widgets/src/calendar/calendar-event-list.tsx @@ -19,6 +19,7 @@ import type { CalendarEvent } from "@homarr/integrations/types"; import { useI18n } from "@homarr/translation/client"; import classes from "./calendar-event-list.module.css"; +import { offscreenRowStyle } from "../common/offscreen-rows"; interface CalendarEventListProps { events: CalendarEvent[]; @@ -40,11 +41,12 @@ export const CalendarEventList = ({ events }: CalendarEventListProps) => { > {events.map((event, eventIndex) => ( - + {event.image !== null && ( 55 (-59%) + * layout objects 8346 -> 5117 (-41%) + * + * `content-visibility: auto` lets the browser skip all of that for a row that is scrolled out of + * view. Nothing leaves the DOM, so scrolling, keyboard navigation and in-page search behave exactly + * as before — this is not virtualisation. + * + * `contain-intrinsic-size` supplies a placeholder height for skipped rows. Without it the scrollbar + * jumps as rows enter and leave, because a skipped row would otherwise measure zero. Pass the + * approximate row height; being wrong only affects scrollbar smoothness, not correctness. + * + * Only worth applying to a list whose length is driven by remote data. On a list that always fits its + * tile the containment costs a little and saves nothing, and on non-list content — charts, editors, + * anything that measures itself — skipping layout can be actively wrong. + */ +export const offscreenRowStyle = (approximateRowHeight: number): CSSProperties => ({ + contentVisibility: "auto", + containIntrinsicSize: `auto ${approximateRowHeight}px`, +}); diff --git a/packages/widgets/src/notifications/component.tsx b/packages/widgets/src/notifications/component.tsx index 3b04393d0..e36fe08d8 100644 --- a/packages/widgets/src/notifications/component.tsx +++ b/packages/widgets/src/notifications/component.tsx @@ -10,6 +10,7 @@ import { useTimeAgo } from "@homarr/common"; import { useScopedI18n } from "@homarr/translation/client"; import type { WidgetComponentProps } from "../definition"; +import { offscreenRowStyle } from "../common/offscreen-rows"; export default function NotificationsWidget({ options, integrationIds }: WidgetComponentProps<"notifications">) { const { data: notificationIntegrations = [] } = clientApi.widget.notifications.getNotifications.useQuery({ @@ -43,7 +44,7 @@ export default function NotificationsWidget({ options, integrationIds }: WidgetC radius={board.itemRadius} w="100%" p="sm" - style={{ color: "inherit", textDecoration: "none" }} + style={{ color: "inherit", textDecoration: "none", ...offscreenRowStyle(72) }} > {!options.hideLogos && notification.source?.iconUrl && ( diff --git a/packages/widgets/src/rssFeed/component.tsx b/packages/widgets/src/rssFeed/component.tsx index 626f87328..dc0952bf5 100644 --- a/packages/widgets/src/rssFeed/component.tsx +++ b/packages/widgets/src/rssFeed/component.tsx @@ -10,6 +10,7 @@ import { useRequiredBoard } from "@homarr/boards/context"; import type { WidgetComponentProps } from "../definition"; import classes from "./component.module.scss"; +import { offscreenRowStyle } from "../common/offscreen-rows"; const useLiveFeedEntries = (input: RouterInputs["widget"]["rssFeed"]["getFeeds"]) => { const { data: feedEntries = [] } = clientApi.widget.rssFeed.getFeeds.useQuery(input); @@ -37,18 +38,19 @@ export default function RssFeed({ options, width }: WidgetComponentProps<"rssFee key={feedEntry.id} component={"a"} href={feedEntry.link} + style={offscreenRowStyle(96)} radius={board.itemRadius} target="_blank" w="100%" p="sm" > {feedEntry.enclosure !== undefined && ( - backdrop + backdrop )} {feedEntry.enclosure !== undefined && options.showPosterImage && !isNarrow && ( - {feedEntry.title} + {feedEntry.title} )}