-
Notifications
You must be signed in to change notification settings - Fork 4
Add up down arrows to section and children #560
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
Add up down arrows to section and children #560
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughAdded page and section reordering functionality to left sidebar settings components. Pages can be reordered with up/down buttons, and sections along with their child items can be reordered independently. Changes persist to Roam via roamAlphaAPI.moveBlock. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as Component UI
participant Handler as Move Handler
participant State as Local State
participant API as roamAlphaAPI
User->>UI: Click up/down button on page/section
activate UI
UI->>Handler: onMove(index, direction)
activate Handler
Handler->>State: Reorder items in state
State-->>Handler: State updated
alt Has parent block (childrenUid)
Handler->>API: moveBlock(uid, parentUid, index)
activate API
API-->>Handler: Block moved
deactivate API
Handler->>Handler: Trigger refresh/notify
end
deactivate Handler
Handler-->>UI: Complete
deactivate UI
UI->>User: Render updated order
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes
Possibly related PRs
Pre-merge checks✅ Passed checks (3 passed)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/roam/src/components/settings/LeftSidebarGlobalSettings.tsx (1)
20-34: PageItem movement wiring looks good; onRemove callback can be cleaner
- The new
index/isFirst/isLast/onMoveprops and the ButtonGroup (up/down/trash) are wired correctly, with appropriate disabled states and clear titles.- Minor type/clarity nit:
onRemoveis typed as(page: RoamBasicNode) => void, but the parent passes a zero-arg wrapperonRemove={() => void removePage(page)}andPageItemthen callsonRemove(page). For consistency and to avoid subtle TS friction, consider either:
- Changing the prop to
onRemove: () => voidand callingonClick={onRemove}(or() => onRemove()), or- Leaving the prop type as-is but passing
onRemove={removePage}and callingonClick={() => void onRemove(page)}.- This keeps the API shape obvious and avoids mixing closure-based and argument-based styles for the same callback.
Based on learnings
Also applies to: 37-60, 329-337
apps/roam/src/components/settings/LeftSidebarPersonalSettings.tsx (1)
5-11: Section movement controls are well‑wired; minor Button sizing nit
- The new SectionItem props (
index,isFirst,isLast,onMoveSection) and the ButtonGroup hooks (onMoveSection(index, "up" | "down")with correct disabled states) look solid, and the parent mapping passes the right values.- Small UI consistency point: in the section header ButtonGroup, the up/down buttons are
small, but the “Add children / Edit section settings” and “Remove section” buttons are not, so they’ll render larger than the arrows and larger than the analogous controls in global settings. Consider addingsmallto those two buttons for a consistent look.Also applies to: 29-48, 307-341, 593-605
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/roam/src/components/settings/LeftSidebarGlobalSettings.tsx(4 hunks)apps/roam/src/components/settings/LeftSidebarPersonalSettings.tsx(7 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-11T19:09:58.252Z
Learnt from: maparent
Repo: DiscourseGraphs/discourse-graph PR: 337
File: apps/roam/src/components/DiscourseFloatingMenu.tsx:43-43
Timestamp: 2025-08-11T19:09:58.252Z
Learning: The roam subdirectory (apps/roam) is constrained to React 17 and cannot use React 18+ features like createRoot API. ReactDOM.render should be used instead of createRoot in this subdirectory.
Applied to files:
apps/roam/src/components/settings/LeftSidebarGlobalSettings.tsxapps/roam/src/components/settings/LeftSidebarPersonalSettings.tsx
🔇 Additional comments (3)
apps/roam/src/components/settings/LeftSidebarGlobalSettings.tsx (1)
142-169: VerifymovePageRoam order calculation (possible off‑by‑one when moving down)
- The local reordering logic (guards for first/last, splice/remove/insert,
setPages(newPages)) looks correct.- The persistence step uses
order = direction === "down" ? newIndex + 1 : newIndexwhen callingwindow.roamAlphaAPI.moveBlock. Depending on Roam’s exactordersemantics (0‑based final index vs. insertion position), the+ 1for"down"could cause the page to jump more than one position.- Since the same pattern is reused for sections/children in
LeftSidebarPersonalSettings.tsx, it’d be good to confirm in Roam (e.g., with 3–4 children) that a single “move down” click moves the item by exactly one slot and adjust the formula if needed.apps/roam/src/components/settings/LeftSidebarPersonalSettings.tsx (2)
220-263: Child reordering logic looks correct; confirm Roamorderoffset for down moves
moveChild’s guards for first/last, cloning ofsection.children, splice‑remove‑insert, andsetSectionsupdate all look correct and match the rendered disable states on the child up/down buttons.- As with
movePage, the persistence step usesorder = direction === "down" ? newIndex + 1 : newIndexinwindow.roamAlphaAPI.moveBlock. If Roam interpretsorderas the final zero‑based index, the+ 1could move the child two positions when going down.- Please verify behavior in Roam (e.g., with several children) and align this calculation with whatever you confirm is correct, keeping it consistent with the global settings reordering.
Also applies to: 375-409
519-546: Section reordering mirrors global behavior; double‑check moveBlockordersemantics
- The
moveSectionhandler correctly prevents moving the first/last sections out of bounds, rebuilds the sections array via splice/remove/insert, and updates state; the per‑sectionisFirst/isLastprops and header buttons line up with that logic.- As in
movePageandmoveChild, the Roam persistence usesorder = direction === "down" ? newIndex + 1 : newIndex. To ensure sections move exactly one slot per click, please confirm that this formula matches Roam’smoveBlockcontract and adjust (and keep in sync with global/child reordering) if needed.Also applies to: 593-605
mdroidian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Might be worth only showing on hover, with a slight delay (will reduce some noise).

Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.