Files
ontime/apps/client/src/views/ViewLoader.tsx
T
Claude e9de1ec19f fix: prevent white background flash and overscroll on Safari iOS
- Set background-color: #101010 on html/body/.App so the Safari iOS
  rubber-band overscroll area is dark instead of white
- Always render body background style in ViewLoader (not just during
  Suspense fallback) so keyColour param and --background-color-override
  propagate to the body for the overscroll region
- Add viewport-fit=cover, apple-mobile-web-app meta tags for proper
  iOS notch/safe-area handling
- Fix manifest.json background_color from #ffffff to #101010
- Align theme_color across both manifests to #101010

https://claude.ai/code/session_016z5vU45pexTdkQV2eHJqh4
2026-05-09 16:35:53 +00:00

44 lines
1.5 KiB
TypeScript

import { PropsWithChildren, Suspense } from 'react';
import useCssOverride from '../common/hooks-query/useCssOverride';
import useViewSettings from '../common/hooks-query/useViewSettings';
import Loader from './common/loader/Loader';
const scriptTagId = 'ontime-stylesheet-override';
function OverrideStyles() {
'use memo';
const { data: settings } = useViewSettings();
const { overrideStyles } = settings;
const { data: css } = useCssOverride(overrideStyles);
const cssBlob = URL.createObjectURL(new Blob([css], { type: 'text/css' }));
//@ts-expect-error disabled exists on link when rel='stylesheet' https://react.dev/reference/react-dom/components/link#props
return <link id={scriptTagId} rel='stylesheet' href={cssBlob} precedence='high' disabled={!overrideStyles} />;
}
export default function ViewLoader({ children }: PropsWithChildren) {
'use memo';
// we need to be able to override the background colour with the key param
const searchParams = new URLSearchParams(window.location.search);
const colourFromParams = searchParams.get('keyColour') ?? '#101010';
// always keep body background in sync so Safari iOS overscroll area matches the view
const bodyBgStyle = `body { background-color: var(--background-color-override, ${colourFromParams}); }`;
return (
<Suspense
fallback={
<>
<style>{bodyBgStyle}</style>
<Loader />
</>
}
>
<style>{bodyBgStyle}</style>
<OverrideStyles />
{children}
</Suspense>
);
}