-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
@@ -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 ) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can no longer see the "unexpected error" overlay over the editor. The console still shows an error (a different one):
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in SlotComponent (created by Context.Consumer)
in Slot (created by __experimentalBlockSettingsMenuPluginsExtensionSlot)
in __experimentalBlockSettingsMenuPluginsExtensionSlot (created by Dropdown)
in div (created by MenuGroup)
in div (created by MenuGroup)
in MenuGroup (created by WithInstanceId(MenuGroup))
in WithInstanceId(MenuGroup) (created by Dropdown)
in div (created by NavigableContainer)
in NavigableContainer (created by ForwardRef(NavigableContainer))
in ForwardRef(NavigableContainer) (created by ForwardRef(NavigableMenu))
in ForwardRef(NavigableMenu) (created by Dropdown)
in div (created by Animate)
in div (created by IsolatedEventContainer)
in IsolatedEventContainer (created by Animate)
in Animate (created by Popover)
in PopoverDetectOutside (created by WithFocusOutside(PopoverDetectOutside))
in div (created by WithFocusOutside(PopoverDetectOutside))
in WithFocusOutside(PopoverDetectOutside) (created by Popover)
in Unknown (created by FocusReturn)
in div (created by FocusReturn)
in FocusReturn (created by Context.Consumer)
in WithFocusReturn(Component) (created by WithConstrainedTabbing(WithFocusReturn(Component)))
in div (created by WithConstrainedTabbing(WithFocusReturn(Component)))
in WithConstrainedTabbing(WithFocusReturn(Component)) (created by Popover)
in FillComponent (created by Context.Consumer)
in Fill (created by Context.Consumer)
in span (created by Context.Consumer)
in Popover (created by Dropdown)
in div (created by Dropdown)
in Dropdown (created by DropdownMenu)
in DropdownMenu (created by BlockActions)
in div (created by ToolbarContainer)
in ToolbarContainer (created by Toolbar)
in Toolbar (created by BlockActions)
in BlockActions (created by WithDispatch(BlockActions))
in WithDispatch(BlockActions)
in Unknown (created by WithSelect(WithDispatch(BlockActions)))
in WithSelect(WithDispatch(BlockActions)) (created by BlockSettingsMenu)
in BlockSettingsMenu (created by BlockToolbar)
in div (created by BlockToolbar)
in BlockToolbar
in Unknown (created by WithSelect(BlockToolbar))
in WithSelect(BlockToolbar) (created by BlockContextualToolbar)
in div (created by NavigableContainer)
in NavigableContainer (created by ForwardRef(NavigableContainer))
in ForwardRef(NavigableContainer) (created by ForwardRef(NavigableMenu))
in ForwardRef(NavigableMenu) (created by NavigableToolbar)
in NavigableToolbar (created by BlockContextualToolbar)
in BlockContextualToolbar (created by BlockListBlock)
in div (created by BlockListBlock)
in div (created by ForwardRef)
in ForwardRef (created by IgnoreNestedEvents)
in IgnoreNestedEvents (created by ForwardRef(IgnoreNestedEvents))
in ForwardRef(IgnoreNestedEvents) (created by BlockListBlock)
in BlockListBlock
in Unknown
in Unknown (created by (BlockListBlock))
in (BlockListBlock) (created by WithMetaAttributeSource((BlockListBlock)))
in WithMetaAttributeSource((BlockListBlock)) (created by WithFilters(BlockListBlock))
in WithFilters(BlockListBlock) (created by IfCondition(WithFilters(BlockListBlock)))
in IfCondition(WithFilters(BlockListBlock)) (created by WithDispatch(IfCondition(WithFilters(BlockListBlock))))
in WithDispatch(IfCondition(WithFilters(BlockListBlock)))
in Unknown (created by WithSelect(WithDispatch(IfCondition(WithFilters(BlockListBlock)))))
in WithSelect(WithDispatch(IfCondition(WithFilters(BlockListBlock))))
in Unknown (created by Pure(WithViewportMatch(WithSelect(WithDispatch(IfCondition(WithFilters(BlockListBlock)))))))
in Pure(WithViewportMatch(WithSelect(WithDispatch(IfCondition(WithFilters(BlockListBlock)))))) (created by BlockList)
in BlockAsyncModeProvider (created by BlockList)
Considering the original issue is of a well-described scope and this solution fixes it, I'm happy approving this PR. If I can reproduce the other error consistently, I'll file it separately.
Description
As described in issue #18356 currently we see an error in Firefox when removing the navigation block. This is caused by a null value which this PR aims to filter out ahead of time.
Fixes #18356
How has this been tested?
Screenshots
Click "Remove block" on the navigation block:
Result Before:
Result After:
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: