Skip to content

Commit

Permalink
- sort the settings alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbahl committed Jan 11, 2024
1 parent bf22070 commit ed785d5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion wp-blocks/AcfFieldTypeSettingsBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,28 @@ export function AcfFieldTypeSettingsBlock({ fieldTypeSettingsBlockFields }) {
);
}

// copy the nodes so we can sort them before returning
const settings = [...fieldTypeSettings?.nodes];

// sort by name
settings.sort((a, b) => {
let nameA = a.name.toUpperCase(); // ignore upper and lowercase
let nameB = b.name.toUpperCase(); // ignore upper and lowercase
if (nameA < nameB) {
return -1; //nameA comes first
}
if (nameA > nameB) {
return 1; // nameB comes first
}
return 0; // names must be equal
});

return (
<>
<p>Below you will find information about how various ACF field settings can impact how the field will map to the GraphQL Schema and/or modify resolution of the field when queried.</p>
<Card>
<CardHeader className="grid grid-cols-[1fr_110px] items-start space-y-2">
{fieldTypeSettings?.nodes?.map((item, index) => {
{settings?.map((item, index) => {
const { id, name, description, fieldTypeSettingsMeta } = item;
const { impactOnWpgraphql, acfFieldName } = fieldTypeSettingsMeta;

Expand Down

0 comments on commit ed785d5

Please sign in to comment.