Repository navigation
Sort asset gallery filter categories alphabetically - #11790
Open
Ming (MaxonT) wants to merge 1 commit into
Open
Ming (MaxonT) wants to merge 1 commit into
Ming (MaxonT) wants to merge 1 commit into
Conversation
Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
Author
|
Hi Abhijith Chatra (@abchatra), Richard Knoll (@riknoll), could you please review this when you have a moment? In short: Sort asset gallery filter categories alphabetically. I think this will be really valuable. You may want to take a look. Thanks! |
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.
I came across the gallery filter in this issue and sorted its category list by the label people see; I haven't opened it in the editor, so the full build and other locales are untested.
The category list in the image editor gallery filter is built by collecting tags in the order they first appear in the gallery asset metadata, so the order looks arbitrary and differs between asset views.
This change sorts the collected categories by the label shown to the user (the same
rlflookup the filter already uses for display, compared with the user's locale), with the raw tag as a tie-breaker. The sorting is a small pure helper inwebapp/src/galleryTags.ts, called fromImageFieldEditor.getAvailableTags.Tests: added a
sortGalleryTagssuite totests/pxt-editor-test/editorrunner.tscovering alphabetical order, ordering by translated label rather than tag id, no mutation of the input, and deterministic tie-breaking.Not verified: the full
gulpbuild and thepxt-editor-testrunner were not run (dependencies are not installed in my environment). I ran the three new test cases in isolation by compilinggalleryTags.tswith tsc and running them under mocha/chai: 3 passing, and 3 failing when the sort is replaced by a no-op. I also did not check the result visually in the editor.Not addressed: the issue also asks to localize the category names and to rename "Misc". Category labels already go through
rlfat render time; the "Misc" tag is defined in the target's gallery asset metadata (pxt-arcade), not in this repository, so the rename and thelf()extraction comment for it are left for a follow-up.Refs microsoft/pxt-arcade#5197