Skip to content

Commit afecd8b

Browse files
authored
fix: sort Advanced Blocks by default display name (#1817)
1 parent aa8a5bf commit afecd8b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/library-authoring/add-content/AddContent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,18 @@ const AddAdvancedContentView = ({
154154
isBlockTypeEnabled,
155155
}: AddAdvancedContentViewProps) => {
156156
const intl = useIntl();
157+
// Sort block types alphabetically by default display name
158+
const sortedBlockTypes = Object.keys(advancedBlocks).sort((typeA, typeB) => (
159+
advancedBlocks[typeA].displayName.localeCompare(advancedBlocks[typeB].displayName)
160+
));
157161
return (
158162
<>
159163
<div className="d-flex">
160164
<Button variant="tertiary" iconBefore={KeyboardBackspace} onClick={closeAdvancedList}>
161165
{intl.formatMessage(messages.backToAddContentListButton)}
162166
</Button>
163167
</div>
164-
{Object.keys(advancedBlocks).map((blockType) => (
168+
{sortedBlockTypes.map((blockType) => (
165169
isBlockTypeEnabled(blockType) ? (
166170
<AddContentButton
167171
key={`add-content-${blockType}`}

0 commit comments

Comments
 (0)