Skip to content

Conversation

@RoyEJohnson
Copy link
Contributor

@RoyEJohnson RoyEJohnson commented Sep 11, 2025

@RoyEJohnson RoyEJohnson force-pushed the core-1221-fix-layoutParameters-timing-issue branch 2 times, most recently from f7d62b3 to 42d2f77 Compare September 11, 2025 17:06
@RoyEJohnson RoyEJohnson force-pushed the core-1221-fix-layoutParameters-timing-issue branch from 42d2f77 to 48a5d9a Compare September 11, 2025 20:05
@RoyEJohnson RoyEJohnson changed the title CORE-1221: Fix layoutParameters timing issue CORE-1221: Fix layoutParameters issue Sep 11, 2025
@RoyEJohnson RoyEJohnson requested a review from jivey September 11, 2025 20:06

if (['books', 'textbooks'].includes(dir)) {
return (
return path === '' ? <Error404 /> : (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Earlier changes to the router had /books coming up as a blank page when it should 404.
Things like /books/Calculus will reroute to /details/books/Calculus.

);
const Layout = React.useCallback(
({children}: React.PropsWithChildren<object>) => {
const layoutParameterName = layoutParameters.name;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This eliminates the need for the cast. In theory, layoutParameters.name could change before the function call.

if (layoutParameterName === null) {
return <div>{children}</div>;
}
const LoadableLayout = loadable({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defining this separately was causing the bug that is the main thing being addressed by this PR.


export function LayoutUsingData({data, children}: {data: FlexPageData, children: React.ReactNode}) {
function warnAndUseDefault() {
console.warn('No layout set for page');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the issue more obvious. When no layout is defined for the page in the CMS, the page wouldn't render. Now it will render with the default layout, and there will also be a warning.

import FeaturedResourcesSection from '~/pages/details/common/featured-resources/featured-resources';
import ShellContextProvider from '../../../../helpers/shell-context';
import {MemoryRouter} from 'react-router-dom';
import MemoryRouter from '~/../../test/helpers/future-memory-router';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to quiet a bunch of warnings in testing.

Copy link
Member

@jivey jivey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable

@RoyEJohnson RoyEJohnson merged commit cb467f7 into main Sep 11, 2025
3 checks passed
@RoyEJohnson RoyEJohnson deleted the core-1221-fix-layoutParameters-timing-issue branch September 11, 2025 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants