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

Fix inserter / block directory issues #17517

Merged
merged 4 commits into from
Sep 26, 2019

Conversation

talldan
Copy link
Contributor

@talldan talldan commented Sep 23, 2019

Description

I started this PR to fix one issue, but noticed a few related to the same piece of code, so it now fixes three 😄

The fixes are as follows:

Code quality - fix incorrect value for hasItems variable

A late change in #17431 was to rename isMenuEmpty to hasItems, but we forgot to also flip the value of the variable to match the new meaning.

fcb5f74 fixes this by flipping the logic and updating usage of the variable.

Inserter help panel was being displayed when no available blocks in the inserter menu

To reproduce this:

  1. Make sure the Block Directory feature is disabled
  2. Insert a columns block
  3. Select the column
  4. Click the '+' inserter button on the top bar.
  5. Observe that help is displayed, but it's not applicable in this situation.

ef0ea34 fixes this by not rendering the help panel when no blocks are available for insert.

Block directory showing a loading spinner when no block available and no search term entered

To reproduce this:

  1. Make sure the Block Directory feature is enabled
  2. Insert a columns block
  3. Select the column
  4. Click the '+' inserter button on the top bar.
  5. Observe that the forever loading spinner is displayed.

ae562e1 fixes this by not rendering the block directory unless there is a search term. There still seems to be a separate issue that the block directory doesn't respect template locking, and I've added this to the list on #17440.

How has this been tested?

Screenshots

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.

@talldan talldan added [Type] Bug An existing feature does not function as intended [Feature] Inserter The main way to insert blocks using the + button in the editing interface [Feature] Block Directory Related to the Block Directory, a repository of block plugins labels Sep 23, 2019
@talldan talldan self-assigned this Sep 23, 2019
@talldan talldan added the Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code label Sep 23, 2019
@gziolo gziolo added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Sep 25, 2019
Copy link
Member

@noisysocks noisysocks left a comment

Choose a reason for hiding this comment

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

Fixes the issues as described—thanks for following up on this! 👍

packages/block-editor/src/components/inserter/menu.js Outdated Show resolved Hide resolved
De Morgan'd, whatever that is

Co-Authored-By: Robert Anderson <robert@noisysocks.com>
@talldan talldan added this to the Gutenberg 6.6 milestone Sep 26, 2019
@talldan talldan merged commit f4fe743 into master Sep 26, 2019
@talldan talldan deleted the fix/spinner-when-no-available-blocks branch September 26, 2019 07:39
youknowriad pushed a commit that referenced this pull request Sep 30, 2019
* Fix flipped `hasItems` value

* Only show help panel when blocks are available

* Only render the block directory when a search term has been entered

* Make boolean logic more readable

De Morgan'd, whatever that is

Co-Authored-By: Robert Anderson <robert@noisysocks.com>
youknowriad pushed a commit that referenced this pull request Sep 30, 2019
* Fix flipped `hasItems` value

* Only show help panel when blocks are available

* Only render the block directory when a search term has been entered

* Make boolean logic more readable

De Morgan'd, whatever that is

Co-Authored-By: Robert Anderson <robert@noisysocks.com>
@jorgefilipecosta jorgefilipecosta removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins [Feature] Inserter The main way to insert blocks using the + button in the editing interface Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants