Prevent "EmptyViewAbsoluteCentered" from overlapping content

Regression 1f7fe5f20e
This commit is contained in:
schroda
2024-12-21 23:21:55 +01:00
parent 570b831604
commit a4f1aa3234
8 changed files with 8 additions and 30 deletions

View File

@@ -27,11 +27,10 @@ export interface EmptyViewProps {
messageExtra?: JSX.Element | string; messageExtra?: JSX.Element | string;
retry?: () => void; retry?: () => void;
noFaces?: boolean; noFaces?: boolean;
topOffset?: number;
sx?: SxProps<Theme>; sx?: SxProps<Theme>;
} }
export function EmptyView({ message, messageExtra, retry, noFaces, topOffset = 0, sx }: EmptyViewProps) { export function EmptyView({ message, messageExtra, retry, noFaces, sx }: EmptyViewProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const errorFace = useMemo(() => getRandomErrorFace(), []); const errorFace = useMemo(() => getRandomErrorFace(), []);
@@ -42,9 +41,9 @@ export function EmptyView({ message, messageExtra, retry, noFaces, topOffset = 0
textAlign: 'center', textAlign: 'center',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
minWidth: '100%', minWidth: '-webkit-fill-available',
minHeight: `calc(100% - ${topOffset}px)`, maxWidth: '100%',
mt: `${topOffset}px`, minHeight: '100%',
...sx, ...sx,
}} }}
> >

View File

@@ -14,8 +14,7 @@ export function EmptyViewAbsoluteCentered({ sx, ...emptyViewProps }: EmptyViewPr
{...emptyViewProps} {...emptyViewProps}
sx={{ sx={{
position: 'absolute', position: 'absolute',
top: 0, minHeight: '-webkit-fill-available',
left: 0,
...sx, ...sx,
}} }}
/> />

View File

@@ -207,7 +207,6 @@ export function Extensions({ tabsMenuHeight }: { tabsMenuHeight: number }) {
fetchExtensions().catch(defaultPromiseErrorHandler('Extensions::refetchExtensions')); fetchExtensions().catch(defaultPromiseErrorHandler('Extensions::refetchExtensions'));
} }
}} }}
topOffset={tabsMenuHeight}
/> />
); );
} }

View File

@@ -238,7 +238,6 @@ export const MangaGrid: React.FC<IMangaGridProps> = ({
isLoading, isLoading,
message, message,
messageExtra, messageExtra,
topOffset,
hasNextPage, hasNextPage,
loadMore, loadMore,
gridLayout, gridLayout,
@@ -349,7 +348,6 @@ export const MangaGrid: React.FC<IMangaGridProps> = ({
message={message ?? t('manga.error.label.no_mangas_found')} message={message ?? t('manga.error.label.no_mangas_found')}
messageExtra={messageExtra} messageExtra={messageExtra}
retry={retry} retry={retry}
topOffset={topOffset}
/> />
); );
} }

View File

@@ -104,7 +104,6 @@ export const Migration = ({ tabsMenuHeight }: { tabsMenuHeight: number }) => {
message={t('global.error.label.failed_to_load_data')} message={t('global.error.label.failed_to_load_data')}
messageExtra={error.message} messageExtra={error.message}
retry={() => refetch().catch(defaultPromiseErrorHandler('Migration::refetch'))} retry={() => refetch().catch(defaultPromiseErrorHandler('Migration::refetch'))}
topOffset={tabsMenuHeight}
/> />
); );
} }

View File

@@ -53,7 +53,6 @@ import { MangaIdInfo } from '@/modules/manga/Manga.types.ts';
import { GridLayout } from '@/modules/core/Core.types.ts'; import { GridLayout } from '@/modules/core/Core.types.ts';
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts'; import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
import { getErrorMessage } from '@/lib/HelperFunctions.ts'; import { getErrorMessage } from '@/lib/HelperFunctions.ts';
import { useResizeObserver } from '@/modules/core/hooks/useResizeObserver.tsx';
const DEFAULT_SOURCE: Pick<SourceType, 'id'> = { id: '-1' }; const DEFAULT_SOURCE: Pick<SourceType, 'id'> = { id: '-1' };
@@ -250,16 +249,6 @@ export function SourceMangas() {
const currentQuery = useRef(query); const currentQuery = useRef(query);
const currentAbortRequest = useRef<(reason: any) => void>(() => {}); const currentAbortRequest = useRef<(reason: any) => void>(() => {});
const contentTypeMenuRef = useRef<HTMLDivElement>(null);
const [contentTypeMenuHeight, setContentTypeMenuHeight] = useState(0);
useResizeObserver(
contentTypeMenuRef,
useCallback(
() => setContentTypeMenuHeight(contentTypeMenuRef.current?.clientHeight ?? 0),
[contentTypeMenuRef],
),
);
const didSearchChange = currentQuery.current !== query; const didSearchChange = currentQuery.current !== query;
if (didSearchChange && contentType === SourceContentType.SEARCH) { if (didSearchChange && contentType === SourceContentType.SEARCH) {
currentQuery.current = query; currentQuery.current = query;
@@ -443,7 +432,7 @@ export function SourceMangas() {
return ( return (
<StyledGridWrapper> <StyledGridWrapper>
<ContentTypeMenu ref={contentTypeMenuRef} sx={{ top: `${appBarHeight}px` }}> <ContentTypeMenu sx={{ top: `${appBarHeight}px` }}>
<ContentTypeButton <ContentTypeButton
variant={contentType === SourceContentType.POPULAR ? 'contained' : 'outlined'} variant={contentType === SourceContentType.POPULAR ? 'contained' : 'outlined'}
startIcon={<FavoriteIcon />} startIcon={<FavoriteIcon />}
@@ -479,7 +468,6 @@ export function SourceMangas() {
loadMore={loadMore} loadMore={loadMore}
message={message} message={message}
messageExtra={messageExtra} messageExtra={messageExtra}
topOffset={contentTypeMenuHeight}
isLoading={isLoading} isLoading={isLoading}
gridLayout={sourceGridLayout} gridLayout={sourceGridLayout}
mode="source" mode="source"
@@ -492,7 +480,6 @@ export function SourceMangas() {
message={t('global.error.label.failed_to_load_data')} message={t('global.error.label.failed_to_load_data')}
messageExtra={getErrorMessage(error)} messageExtra={getErrorMessage(error)}
retry={() => loadPage(lastPageNum).catch(defaultPromiseErrorHandler('SourceMangas::refetch'))} retry={() => loadPage(lastPageNum).catch(defaultPromiseErrorHandler('SourceMangas::refetch'))}
topOffset={contentTypeMenuHeight}
/> />
)} )}

View File

@@ -138,15 +138,12 @@ export function Sources({ tabsMenuHeight }: { tabsMenuHeight: number }) {
message={t('global.error.label.failed_to_load_data')} message={t('global.error.label.failed_to_load_data')}
messageExtra={error.message} messageExtra={error.message}
retry={() => refetch().catch(defaultPromiseErrorHandler('Sources::refetch'))} retry={() => refetch().catch(defaultPromiseErrorHandler('Sources::refetch'))}
topOffset={tabsMenuHeight}
/> />
); );
} }
if (sources?.length === 0) { if (sources?.length === 0) {
return ( return <EmptyViewAbsoluteCentered message={t('source.error.label.no_sources_found')} />;
<EmptyViewAbsoluteCentered message={t('source.error.label.no_sources_found')} topOffset={tabsMenuHeight} />
);
} }
return ( return (

View File

@@ -147,7 +147,7 @@ export const TrackerSearch = ({
/> />
</Stack> </Stack>
</DialogTitle> </DialogTitle>
<DialogContent dividers sx={{ padding: DIALOG_PADDING, height: '100vh' }}> <DialogContent dividers sx={{ padding: DIALOG_PADDING, height: '100vh', position: 'relative' }}>
{!trackerSearch.loading && !trackerSearch.error && !hasResults && ( {!trackerSearch.loading && !trackerSearch.error && !hasResults && (
<EmptyViewAbsoluteCentered message={t('manga.error.label.no_mangas_found')} /> <EmptyViewAbsoluteCentered message={t('manga.error.label.no_mangas_found')} />
)} )}