Closed Bug 2066334 Opened 1 month ago Closed 5 days ago

Sort newtab widget lists alphabetically

Categories

(Firefox :: New Tab Page, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: gharp, Assigned: nina-py)

References

Details

(Whiteboard: [hnt][hnt-wattle])

Attachments

(2 files)

The widget toggle lists in about:preferences (Firefox Home -> Widgets) and in the newtab customize panel ("Manage widgets") are both in a non-sensical order, and they don't match each other.

Both lists should be sorted A-Z by the widget's localized display label, using locale-aware collation; a French user should see the list sorted for French rather than sorted by the en-US string or by internal widget id. Weather is included as a peer of the other widgets, not held out separately.

Current order:

  • about:preferences (AboutPreferences.sys.mjs): Lists, Timer, Sports, Clock, Privacy, Crossword, Stocks, Picture of the day, Weather
  • Customize panel (WidgetsManagementPanel.jsx): Weather, Timer, Lists, Sports, Clock, Privacy, Crossword, Stocks, Picture of the day

Widget availability

Not every widget is available to every user. Availability is gated per-user by system prefs and Nimbus/trainhop config, which is targeted by region among other things, and most widgets default to off entirely today. A user in one country may see a very different set than a user in another.

Acceptance criteria

  1. In about:preferences -> Firefox Home -> Widgets, the visible widget toggles render in A-Z order by displayed label, Weather included.
  2. In the newtab customize panel -> Manage widgets, the visible widget toggles render in A-Z order by displayed label.
  3. Sorting is locale-aware and operates on the localized string, not the widget id, pref name, or en-US label. Verified in at least one non-English locale with accents or a different alphabet.
  4. Availability filtering is unchanged, and the sorted list is contiguous when only a subset of widgets is available.
  5. Order is stable across page loads, and unaffected by which widgets the user has toggled on.
  6. Both surfaces show the same relative order for any given locale.
  7. Test coverage on both surfaces, including a reduced widget set and the addition of a new widget.

QA note: Weather already happens to sort last in en-US, so en-US alone won't catch a Weather placement bug. Test a locale where it doesn't.

Notes for implementation

  • Labels come from Fluent, so the sort key isn't available at list-construction time. Worth avoiding a visible reorder flash on open.
  • The two surfaces use different Fluent ids for the same widget, e.g. home-prefs-clocks-header vs newtab-custom-widget-clock-toggle.
  • WIDGET_REGISTRY has an order field, but it is page-placement order (user-draggable, trainhop-overridable) and shouldn't be repurposed for list order.
  • Bug 2046503 covers generating the about:preferences widget list dynamically from WidgetsRegistry.mjs. Landing that first would make most of this free.

Out of scope

  • Widget layout order on the newtab page itself (placement and drag-and-drop).
  • Which widgets are available to which users.
  • Widget labels and strings.
  • Grouping, sectioning, or search within the lists.
Assignee: nobody → npypchenko
Status: NEW → ASSIGNED

The Manage widgets list in the New Tab customize panel is now generated from
WIDGET_REGISTRY instead of being written out toggle by toggle. Each registry
entry gained a customizeL10nId naming its panel label and a
customizeEventSource carrying its telemetry source, so a new widget needs no
edit to the panel and a retired widget drops out on its own. Crossword gained
a Fluent string of its own for the first time; a migration recipe copies its
translations from the about:preferences Crossword label, and the classic
customize menu switched to the same string.

The classic (Nova off) customize menu still renders its own widget toggles from
the mayHave* and enabledWidgets props, so that prop chain stayed and has
been marked for Nova cleanup; only its retired Sports links were removed. The
check that decides whether Weather may be shown moved out of Base.jsx into the
registry as isWeatherAvailable, where the panel shares it.

Telemetry is unchanged: the generated toggles carry the same event sources and
pref names as before, and the outer Widgets toggle records the same events for
a flip as it did. Part 2 will sort both this list and the about:preferences
group alphabetically; until it lands, the panel lists widgets in registry
order. Three toggle ids changed to their registry ids (focusTimer-toggle,
pictureOfTheDay-toggle, recentSearches-toggle), and the browser test now
finds the Weather toggle by its own id.

Both widget toggle lists now sort A-Z by the label the user sees, in the app
locale: the Firefox Home > Widgets group in about:preferences and the
"Manage widgets" subpanel of the New Tab customize panel. Part 1 put both
lists in registry order; this patch replaces that with an order users can
scan.

Each surface sorts by its own strings. The about:preferences labels and
the customize panel labels are separate string sets, kept so that either
can be retired later, so a locale that translated the two sets differently
can order the two lists differently; in en-US they agree. The comparison is
localeCompare with no arguments, which collates in the app locale on both
surfaces, and a label with no message sorts under its widget id, so the
order is always defined.

Setting registration order and the standalone Weather row are unchanged;
nested Weather sorts among the other widgets. The "Manage widgets" subpanel
renders no toggles until its labels have resolved, which happens when the
page loads and before the subpanel can be opened, so an unsorted list is
never shown. Tests on both surfaces pin hand-written orders for English,
German, Greek and Japanese labels taken from Firefox's own translations,
plus a reduced set, a missing label and a failing lookup.

Depends on: 2074268
Pushed by npypchenko@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a7b8520dca32 https://hg.mozilla.org/integration/autoland/rev/ba723c91bdea Part 1: Build the customize panel widget toggles from WidgetsRegistry.mjs r=fluent-reviewers,maxx,bolsson https://github.com/mozilla-firefox/firefox/commit/c5fc0e529924 https://hg.mozilla.org/integration/autoland/rev/ac08d6cbc9b7 Part 2: Sort the widget toggle lists alphabetically by localised label r=maxx
Status: ASSIGNED → RESOLVED
Closed: 5 days ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: