Skip to content

Sort asset gallery filter categories alphabetically - #11790

Open
Ming (MaxonT) wants to merge 1 commit into
microsoft:masterfrom
MaxonT:contrib/5197-auto
Open

Ming (MaxonT) wants to merge 1 commit into
microsoft:masterfrom
MaxonT:contrib/5197-auto

Conversation

@MaxonT

Copy link
Copy Markdown

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 rlf lookup 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 in webapp/src/galleryTags.ts, called from ImageFieldEditor.getAvailableTags.

Tests: added a sortGalleryTags suite to tests/pxt-editor-test/editorrunner.ts covering alphabetical order, ordering by translated label rather than tag id, no mutation of the input, and deterministic tie-breaking.

Not verified: the full gulp build and the pxt-editor-test runner were not run (dependencies are not installed in my environment). I ran the three new test cases in isolation by compiling galleryTags.ts with 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 rlf at render time; the "Misc" tag is defined in the target's gallery asset metadata (pxt-arcade), not in this repository, so the rename and the lf() extraction comment for it are left for a follow-up.

Refs microsoft/pxt-arcade#5197

Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
@MaxonT

Copy link
Copy Markdown
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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant