fix: suggestions object key with constructor#2586
Merged
Conversation
✅ Deploy Preview for rspress-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
Fixes an issue with the suggestions object implementation by replacing a plain JavaScript object with a Map to properly handle keys with constructor properties.
- Replaces
Record<string, DefaultMatchResultItem[]>withMap<string, DefaultMatchResultItem[]> - Updates all object access patterns to use Map methods (
.has(),.get(),.set()) - Changes iteration from
Object.keys()toArray.from(map.keys())
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
replace ? -> ! Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
SoonIter
approved these changes
Sep 11, 2025
Member
|
Interesting, anothor option is Map is better than |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request refactors the way search suggestions are grouped and accessed in the
SearchPanelcomponent. The main change is switching from using a plain JavaScript object to aMapfor grouping suggestions, which improves code clarity and consistency when handling dynamic keys.Refactor of suggestions grouping and iteration:
normalizeSuggestionsfunction to return aMap<string, DefaultMatchResultItem[]>instead of aRecord<string, DefaultMatchResultItem[]>, and updated the grouping logic to useMapmethods.MapusingArray.from(normalizedSuggestions.keys())andnormalizedSuggestions.get(group)instead of object property access.Related Issue
#2585
Checklist