Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation block: prevent error in Firefox when removing the navigation block #18455

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/block-navigation/list.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { map } from 'lodash';
import { isNil, map, omitBy } from 'lodash';
import classnames from 'classnames';

/**
Expand Down Expand Up @@ -59,7 +59,7 @@ export default function BlockNavigationList( {
*/
/* eslint-disable jsx-a11y/no-redundant-roles */
<ul className="editor-block-navigation__list block-editor-block-navigation__list" role="list">
{ map( blocks, ( block ) => {
{ map( omitBy( blocks, isNil ), ( block ) => {
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch! I have a newbie question: How does a nil value end up in blocks array? Is there a use-case for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure there is a use case for it and it probably shouldn't end up there. That's something we should look at separately. This PR mainly addresses the fact that it did end up here and we should thus safeguard against that happening.

const blockType = getBlockType( block.name );
const isSelected = block.clientId === selectedBlockClientId;

Expand Down