Skip to content

Commit

Permalink
Block Editor: Validate options for the 'HeadingLevelDropdown' compone…
Browse files Browse the repository at this point in the history
…nt (WordPress#65425)


Co-authored-by: philwp <philwebs@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
  • Loading branch information
4 people authored Sep 26, 2024
1 parent 7d883a4 commit f624423
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ export default function HeadingLevelDropdown( {
value,
onChange,
} ) {
const validOptions = options
.filter(
( option ) => option === 0 || HEADING_LEVELS.includes( option )
)
.sort( ( a, b ) => a - b ); // Sorts numerically in ascending order;

return (
<ToolbarDropdownMenu
popoverProps={ POPOVER_PROPS }
icon={ <HeadingLevelIcon level={ value } /> }
label={ __( 'Change level' ) }
controls={ options.map( ( targetLevel ) => {
controls={ validOptions.map( ( targetLevel ) => {
const isActive = targetLevel === value;
return {
icon: <HeadingLevelIcon level={ targetLevel } />,
Expand Down

0 comments on commit f624423

Please sign in to comment.