commit cd8497d076d6e13db9b345c27ed1232195d3f017
parent 4a086c0d65e33f30b1e817f78e212bc2965cba29
Author: Tim Giles <tgiles@mozilla.com>
Date: Mon, 8 Dec 2025 21:19:18 +0000
Bug 2002939 - Fix payment methods ordering in subpage. r=credential-management-reviewers,mkennedy,dimi
Since we want to show the newly added payment methods first, we sort the
records by their timeCreated field before we create the record's box
item configuration.
Differential Revision: https://phabricator.services.mozilla.com/D275123
Diffstat:
1 file changed, 35 insertions(+), 33 deletions(-)
diff --git a/toolkit/components/formautofill/FormAutofillPreferences.sys.mjs b/toolkit/components/formautofill/FormAutofillPreferences.sys.mjs
@@ -237,42 +237,44 @@ export class FormAutofillPreferences {
return [];
}
- const items = records.map(record => {
- const config = {
- id: "payment-item",
- control: "moz-box-item",
- l10nId: "payment-moz-box-item",
- iconSrc: "chrome://formautofill/content/icon-credit-card-generic.svg",
- l10nArgs: {
- cardNumber: record["cc-number"].replace(/^(\*+)(\d+)$/, "$2$1"),
- expDate: record["cc-exp"].replace(/^(\d{4})-\d{2}$/, "XX/$1"),
- },
- options: [
- {
- control: "moz-button",
- iconSrc: "chrome://global/skin/icons/delete.svg",
- type: "icon",
- controlAttrs: {
- slot: "actions",
- action: "remove",
- guid: record.guid,
- },
+ const items = records
+ .sort(record => record.timeCreated)
+ .map(record => {
+ const config = {
+ id: "payment-item",
+ control: "moz-box-item",
+ l10nId: "payment-moz-box-item",
+ iconSrc: "chrome://formautofill/content/icon-credit-card-generic.svg",
+ l10nArgs: {
+ cardNumber: record["cc-number"].replace(/^(\*+)(\d+)$/, "$2$1"),
+ expDate: record["cc-exp"].replace(/^(\d{4})-\d{2}$/, "XX/$1"),
},
- {
- control: "moz-button",
- iconSrc: "chrome://global/skin/icons/edit.svg",
- type: "icon",
- controlAttrs: {
- slot: "actions",
- action: "edit",
- guid: record.guid,
+ options: [
+ {
+ control: "moz-button",
+ iconSrc: "chrome://global/skin/icons/delete.svg",
+ type: "icon",
+ controlAttrs: {
+ slot: "actions",
+ action: "remove",
+ guid: record.guid,
+ },
},
- },
- ],
- };
+ {
+ control: "moz-button",
+ iconSrc: "chrome://global/skin/icons/edit.svg",
+ type: "icon",
+ controlAttrs: {
+ slot: "actions",
+ action: "edit",
+ guid: record.guid,
+ },
+ },
+ ],
+ };
- return config;
- });
+ return config;
+ });
return [
{