Skip to content

feat: subpages component improvements - #2488

Open
salihudickson wants to merge 3 commits into
mainfrom
feat/subpages
Open

feat: subpages component improvements#2488
salihudickson wants to merge 3 commits into
mainfrom
feat/subpages

Conversation

@salihudickson

Copy link
Copy Markdown
Collaborator

closes: #1568

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved issues affect accessibility, localization, nested loading, pagination, and sorting behavior.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Improves subpage sorting and recursive nested-page rendering.

Changes:

  • Adds persisted sort options and editor controls.
  • Supports expandable, lazy-loaded nested subpages.
  • Adds sorting utilities and nested-row styling.
File summaries
File Description
packages/editor-ext/src/lib/subpages/subpages.ts Adds sort attributes and commands.
packages/editor-ext/src/lib/subpages/index.ts Exports the sort type.
apps/client/src/features/editor/components/subpages/subpages.utils.ts Implements subpage sorting.
apps/client/src/features/editor/components/subpages/subpages.module.css Styles nested rows and controls.
apps/client/src/features/editor/components/subpages/subpages-view.tsx Integrates sorting and recursive items.
apps/client/src/features/editor/components/subpages/subpages-menu.tsx Adds sort controls.
apps/client/src/features/editor/components/subpages/subpage-item.tsx Renders expandable nested subpages.
Review details

Suppressed comments (4)

apps/client/src/features/editor/components/subpages/subpage-item.tsx:62

  • This is an infinite query with a cursor and a 100-item limit, but the nested renderer only flattens pages already fetched and never calls fetchNextPage or exposes hasNextPage. A parent with more than 100 children will silently omit the remainder, so load all pages or provide a load-more path.
    const pages = data?.pages.flatMap((result) => result.items) || [];
    return sortSubpages(pages, sortBy);

apps/client/src/features/editor/components/subpages/subpages-view.tsx:23

  • sortSubpages only treats "default" as the position-order sentinel; any other value falls into the title-ascending branch. Using "position" here therefore changes nodes with a missing sortBy attribute to alphabetical order instead of preserving the existing position order. Use "default" as the fallback.
  const sortBy = (props.node.attrs.sortBy || "position") as SubpagesSortBy;

apps/client/src/features/editor/components/subpages/subpages.utils.ts:3

  • This union duplicates the SubpagesSortBy type exported by @docmost/editor-ext (and now used by the node command). Keeping separate declarations can let the renderer and editor command accept different values; import and re-export the package type here so the existing local imports share one source of truth.
export type SubpagesSortBy = "default" | "title-asc" | "title-desc";

apps/client/src/features/editor/components/subpages/subpages.utils.ts:22

  • sortBy is typed as a union, but runtime values are not guaranteed: the view currently falls back to "position", and the node parser accepts arbitrary data-sort-by strings. Such a value skips this default check and is treated as ascending title order below, so malformed or legacy nodes can lose their position ordering. Normalize unsupported values to the default/position branch here.
  if (sortBy === "default") {
    return sortPositionKeys(sortedItems);
  }
  • Files reviewed: 7/7 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +42 to +44
const { data, isLoading } = useGetSidebarPagesQuery(
!shareId && opened ? { pageId: page.id } : undefined
);
Comment thread apps/client/src/features/editor/components/subpages/subpage-item.tsx Outdated
Comment thread apps/client/src/features/editor/components/subpages/subpages-menu.tsx Outdated
@salihudickson
salihudickson marked this pull request as ready for review September 12, 2026 13:26
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.

[Suggestion] Subpages component improvements

2 participants