Use treeFrom/treeExpandTo settings only in "tree" mode

Fix for https://github.com/pnp/sp-dev-fx-webparts/issues/3684
This commit is contained in:
Tobias Blum 2023-05-11 14:44:16 +02:00
parent 089162f740
commit 7ba2adde76
2 changed files with 5 additions and 2 deletions

View File

@ -88,7 +88,7 @@ function pagesReducer(state: PagesState, action: Action): PagesState {
} }
} }
export function usePageApi(currentPageId: number, pageEditFinished: boolean, context: WebPartContext, treeTop: number, treeExpandTo: number): PageApi { export function usePageApi(currentPageId: number, pageEditFinished: boolean, context: WebPartContext, treeTop?: number, treeExpandTo?: number): PageApi {
const [pagesState, pagesDispatch] = useReducer(pagesReducer, { const [pagesState, pagesDispatch] = useReducer(pagesReducer, {
parentPageColumnExists: true, parentPageColumnExists: true,
userCanManagePages: false, userCanManagePages: false,

View File

@ -10,7 +10,10 @@ import { Placeholder } from "@pnp/spfx-controls-react/lib/Placeholder";
import { TreeLayout } from '../Layouts/TreeLayout'; import { TreeLayout } from '../Layouts/TreeLayout';
export const Container: React.FunctionComponent<IContainerProps> = props => { export const Container: React.FunctionComponent<IContainerProps> = props => {
const pagesApi = usePageApi(props.currentPageId, props.pageEditFinished, props.context, props.treeFrom, props.treeExpandTo); // Use props.treeFrom / treeExpandTo value from settings only in display mode "tree"
const treeFrom = (props.pagesToDisplay === PagesToDisplay.Tree) ? props.treeFrom : undefined;
const treeExpandTo = (props.pagesToDisplay === PagesToDisplay.Tree) ? props.treeExpandTo : undefined;
const pagesApi = usePageApi(props.currentPageId, props.pageEditFinished, props.context, treeFrom, treeExpandTo);
let controlToRender = undefined; let controlToRender = undefined;
switch (props.pagesToDisplay) { switch (props.pagesToDisplay) {
case PagesToDisplay.Ancestors: case PagesToDisplay.Ancestors: