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

Conversation

@frontdevde
Copy link
Contributor

frontdevde commented Nov 12, 2019

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?

  • Open latest Firefox
  • Add the experimental navigation block
  • Try removing it, an error appears.
  • Apply this fix
  • Try removing it. No error should appear, the block should be deleted.

Screenshots

Click "Remove block" on the navigation block:

Screen Shot 2019-11-12 at 11 54 15

Result Before:

Screen Shot 2019-11-12 at 11 52 58

Result After:

Screen Shot 2019-11-12 at 11 53 59

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .
@frontdevde frontdevde added this to 👀 PRs to review in Navigation block via automation Nov 12, 2019
@frontdevde frontdevde self-assigned this Nov 12, 2019
@frontdevde frontdevde requested review from noisysocks and mapk Nov 12, 2019
@@ -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 ) => {

This comment has been minimized.

Copy link
@WunderBart

WunderBart Nov 12, 2019

Contributor

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

This comment has been minimized.

Copy link
@frontdevde

frontdevde Nov 12, 2019

Author Contributor

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.

Copy link
Contributor

marekhrabe left a comment

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.

@frontdevde frontdevde merged commit 2102309 into master Nov 12, 2019
2 checks passed
2 checks passed
pull-request-automation
Details
Travis CI - Pull Request Build Passed
Details
Navigation block automation moved this from 👀 PRs to review to ✅ Done Nov 12, 2019
@frontdevde frontdevde deleted the fix/navigation-block-firefox-null-error branch Nov 12, 2019
@youknowriad youknowriad added this to the Gutenberg 7.0 milestone Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.