fix(edit-page): Slug gets -1 appended when editing page#255
Conversation
This offers us the possibility to avoid adding `-1` to the slug if we just edit the page.
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for passing a currentID parameter when suggesting slugs, allowing the slug service to exclude the current page when checking for slug conflicts. This enables editing a page's title without forcing a slug change if the generated slug matches the page's existing slug.
- Added
currentIDparameter throughout the slug suggestion pipeline (API, service, and UI components) - Modified slug conflict detection to exclude the current page being edited
- Removed the
initialTitlecheck in slug suggestion logic - Added test coverage for the new behavior
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/leafwiki-ui/src/lib/api/pages.ts | Added currentId parameter to suggestSlug function signature |
| ui/leafwiki-ui/src/features/page/SlugInputWithSuggestion.tsx | Accepts and passes currentId parameter; removed initialTitle comparison |
| ui/leafwiki-ui/src/features/page/EditPageMetadataDialog.tsx | Made currentId required and passes it to SlugInputWithSuggestion |
| ui/leafwiki-ui/src/features/editor/PageEditor.tsx | Provides page?.id as currentId to the dialog |
| internal/http/api/suggest_slug.go | Extracts and passes currentID query parameter |
| internal/wiki/wiki.go | Updated SuggestSlug to accept and pass currentID parameter |
| internal/wiki/wiki_test.go | Updated test calls with empty string for currentID |
| internal/core/tree/slug_service.go | Modified conflict detection to exclude current page by ID |
| internal/core/tree/slug_service_test.go | Updated tests and added new test case for same-slug scenario |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
cd161d4 to
74abd18
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
ui/leafwiki-ui/src/features/page/SlugInputWithSuggestion.tsx:69
- The
initialTitlevariable is included in the dependency array but is no longer used in the effect logic (removed from the condition on line 38). This is dead code that should be removed from the dependency array.
initialTitle,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
-1 appended when editing page
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This offers us the possibility to avoid adding
-1to the slug if we just edit the page.