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 (#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

1 comment on commit f624423

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in f624423.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11052642316
📝 Reported issues:

Please sign in to comment.