Skip to content

Only update state if we have a valid reference#24496

Merged
talldan merged 3 commits intoWordPress:masterfrom
javidalkaruzi:fix/block-toolbar-unmount
Aug 20, 2020
Merged

Only update state if we have a valid reference#24496
talldan merged 3 commits intoWordPress:masterfrom
javidalkaruzi:fix/block-toolbar-unmount

Conversation

@javidalkaruzi
Copy link
Contributor

Description
This should resolve #24495.

If a block is a child of a group block, it will have a parent selector that is shown when we hover over the block switcher and hidden when we move from it. The function to hide this is called in a setTimeout callback. If the block is unmounted, we still attempt to hide the parent selector via the setTimeout callback. By the time the callback gets executed, it is possible that the component would have already been unmounted.

How has this been tested?

  • Ensure that the existing unit tests were passing
  • Manually test and observed in the browser

Types of changes

Bug fix

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.

@youknowriad youknowriad requested a review from ItsJonQ August 12, 2020 09:07
@youknowriad youknowriad added the [Type] Code Quality Issues or PRs that relate to code quality label Aug 12, 2020
Copy link
Contributor

@talldan talldan left a comment

Choose a reason for hiding this comment

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

I had some trouble reproducing the original issue, but having said that I can see how it could logically happen, and this fix doesn't cause any issues, so it seems good to have the added guard.

Thanks for working on this!

@talldan talldan merged commit 285cff1 into WordPress:master Aug 20, 2020
@github-actions github-actions bot added this to the Gutenberg 8.9 milestone Aug 20, 2020
@javidalkaruzi javidalkaruzi deleted the fix/block-toolbar-unmount branch August 20, 2020 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attempting to set the state on an unmounted component when selecting the block's parent

3 participants