Skip to content

Commit

Permalink
order quick inserter items by frecency (WordPress#23900)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jul 13, 2020
1 parent 97fe260 commit 0335366
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/block-editor/src/components/inserter/quick-inserter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { orderBy } from 'lodash';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -46,7 +51,11 @@ function QuickInserterList( {
onHover,
} ) {
const shownBlockTypes = useMemo(
() => blockTypes.slice( 0, SHOWN_BLOCK_TYPES ),
() =>
orderBy( blockTypes, [ 'frecency' ], [ 'desc' ] ).slice(
0,
SHOWN_BLOCK_TYPES
),
[ blockTypes ]
);
const shownBlockPatterns = useMemo(
Expand Down

0 comments on commit 0335366

Please sign in to comment.