Loading
Add a sort direction toggle to the wiki sidebar
What does this MR do and why?
Adds a sort direction toggle to the wiki sidebar and tidies up its header.
- Sorting: a sort direction button in the sidebar header switches the page tree between ascending and descending order. Nested pages follow the same order, search keeps it, and the choice is saved in the browser so it survives page loads. The sidebar only receives the title, slug, and path of each page, so sorting is alphabetical. Sorting by date would need a backend change. On the "View all pages" page, the sidebar toggle and the list's own sort button stay independent: one orders the sidebar tree, the other the paginated list.
- Header: the sidebar header shows "Wiki" next to the close button, so the "Wiki Pages" heading inside the sidebar goes away. With a custom sidebar, a "Pages" toggle stays at the top of the list because it is what expands the pages list.
- View all pages: a small tertiary button below a divider, instead of a full-width button.
- Icons: "Create a new page under ..." in the sidebar and "New page" in the More actions menu use the
doc-newicon.
Two changes to the shared panel sidebar make this work:
panel_sidebarandLayouts::PanelSidebarComponenttake an optionaltitle:, rendered as a heading next to the close button.PanelSidebarPortalmounts its actions into a target placed before the server-rendered actions. Before, it appended them after, so a Vue button shown to the left of "Add custom sidebar" received keyboard focus after it. The wiki is the only page that uses the portal's actions slot.
References
- Related to #590402 (sorting part of the wiki sidebar enhancements)
Screenshots or screen recordings
| State | Before | After |
|---|---|---|
| Wiki page | ![]() |
![]() |
| Sidebar, default order | ![]() |
![]() |
| Sidebar, descending (new, before has no sort) | ![]() |
![]() |
| Create subpage on hover | ![]() |
![]() |
| More actions menu | ![]() |
![]() |
| Custom sidebar, pages expanded | ![]() |
![]() |
In ascending order, "guides archive" now sorts after the "guides" folder: the sidebar compares slugs one path segment at a time, so a hyphenated sibling no longer jumps ahead of a folder with the same prefix.
How to set up and validate locally
- Open a project wiki page with a few pages, including nested ones, for example https://gdk.test:3000/gitlab-org/gitlab-test/-/wikis/home.
- Check the sidebar header reads "Wiki" next to the close button, followed by the sort button and, if you can create pages, "Add custom sidebar".
- Select the sort button. The tree reverses, including pages inside folders, and the tooltip changes to "Sort direction: Descending".
- Type in "Search pages". The results keep the descending order.
- Reload the page. The order is still descending.
- Press Tab through the header. Focus moves from the close button to the sort button, then to "Add custom sidebar".
- Hover a page in the tree and check the create subpage button uses the
doc-newicon. Open the More actions menu and check "New page" uses it too. - Optional: add a custom sidebar. The "Pages" toggle expands and collapses the page list, and the sort button only shows while the list is expanded.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Sascha Eggenberger











