Fix alphabetical sorting of documents within document type groups in Dev Portal#1361
Fix alphabetical sorting of documents within document type groups in Dev Portal#1361Shakir5665 wants to merge 2 commits into
Conversation
Added sorting functionality for document list based on type and name.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughDocList now computes a non-mutating sorted copy of documents using new helpers that apply a document-type priority and localeCompare tie-breakers; Autocomplete receives this precomputed ChangesDocument sorting refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@portals/devportal/src/main/webapp/source/src/app/components/Apis/Details/Documents/DocList.jsx`:
- Around line 272-285: getDocumentOrder currently returns -1 for unknown types
which makes unknowns sort before known types and allows different unknown-type
documents to interleave by name; change getDocumentOrder to return
documentTypeOrder.length (or another large index) when type is unknown so
unknowns sort after known groups, and update sortDocuments so after computing
typeOrder === 0 it first compares types when both types are unknown (e.g., if
getDocumentOrder(a.type) === documentTypeOrder.length &&
getDocumentOrder(b.type) === documentTypeOrder.length then return
a.type.localeCompare(b.type)) before falling back to name comparison; reference
functions: getDocumentOrder, sortDocuments and the documentTypeOrder array.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 032f8749-7362-4822-ac4a-63b669c5b77f
📒 Files selected for processing (1)
portals/devportal/src/main/webapp/source/src/app/components/Apis/Details/Documents/DocList.jsx
Update document sorting logic to handle missing types.
|



Purpose
This PR fixes the document ordering in the Dev Portal document dropdown.
Previously, documents were only sorted by document type (
HOWTO,SAMPLES,PUBLIC_FORUM,SUPPORT_FORUM,OTHER). As a result, documents within the same type were displayed in the order received from the backend API, which could appear inconsistent.Goals
Solution
Updated the document sorting logic in the Dev Portal document dropdown to:
documentListprop.Testing
Verified the document dropdown ordering using multiple documents with different names under the same document type.
Example:
Before:
After:
The existing document type grouping and ordering remain unchanged.
Fixes #5060