Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imprv: Display page tree in page select modal with scrollbar #9023

Merged
merged 11 commits into from
Sep 3, 2024
27 changes: 16 additions & 11 deletions apps/app/src/client/components/PageSelectModal/PageSelectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useTranslation } from 'next-i18next';
import {
Modal, ModalHeader, ModalBody, ModalFooter, Button,
} from 'reactstrap';
import SimpleBar from 'simplebar-react';

import type { IPageForItem } from '~/interfaces/page';
import { useTargetAndAncestors, useIsGuestUser, useIsReadOnlyUser } from '~/stores-universal/context';
Expand All @@ -22,6 +23,7 @@ import { usePagePathRenameHandler } from '../PageEditor/page-path-rename-utils';

import { TreeItemForModal } from './TreeItemForModal';


export const PageSelectModal: FC = () => {
const {
data: PageSelectModalData,
Expand Down Expand Up @@ -82,20 +84,23 @@ export const PageSelectModal: FC = () => {
isOpen={isOpened}
toggle={closeModal}
centered
size="sm"
>
<ModalHeader toggle={closeModal}>{t('page_select_modal.select_page_location')}</ModalHeader>
<ModalBody>
<ModalBody className="p-0">
<Suspense fallback={<ItemsTreeContentSkeleton />}>
<ItemsTree
CustomTreeItem={TreeItemForModal}
isEnableActions={!isGuestUser}
isReadOnlyUser={!!isReadOnlyUser}
targetPath={targetPath}
targetPathOrId={targetPathOrId}
targetAndAncestorsData={targetAndAncestorsData}
onClickTreeItem={onClickTreeItem}
/>
<SimpleBar style={{ maxHeight: 'calc(85vh - 133px)' }}> {/* 133px = 63px(ModalHeader) + 70px(ModalFooter) */}
<div className="p-3">
<ItemsTree
CustomTreeItem={TreeItemForModal}
isEnableActions={!isGuestUser}
isReadOnlyUser={!!isReadOnlyUser}
targetPath={targetPath}
targetPathOrId={targetPathOrId}
targetAndAncestorsData={targetAndAncestorsData}
onClickTreeItem={onClickTreeItem}
/>
</div>
</SimpleBar>
</Suspense>
</ModalBody>
<ModalFooter>
Expand Down
Loading