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

Display Block Information by matching block variations #27469

Merged
merged 32 commits into from
Dec 23, 2020

Conversation

ntsekouras
Copy link
Contributor

@ntsekouras ntsekouras commented Dec 3, 2020

Description

This PR wants to solve the problem of displaying the proper information of a block, if that block had been created from a block variation.

This is achieved with:

  1. A new hook (useMatchingVariationInformation) which receives a clientId and returns the appropriate block information to display.
  2. An addition of a property (isActive) in Block Variation's settings. This optional property is a function to match block variations. It doesn't check dynamically all block properties to try to find a match, because in many cases it doesn't make sense. An example is embed block where we can have changed the responsive attribute, so a match would not be found.

The changes that have been made affect the Block Card (Inspector Tools), Navigation List View (top bar) and Breadcrumbs.

To make use of the new hook and handle Transforms icon(in toolbar), I need to make BlockSwitcher a function component which is handled in this PR: #27674 to make reviewing easier.
The icon in BlockSwitcher will be handled in a follow up after the refactoring PR lands.

pocVariationsDisplayMatcher

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.

@github-actions
Copy link

github-actions bot commented Dec 3, 2020

Size Change: -888 B (0%)

Total Size: 1.28 MB

Filename Size Change
build/annotations/index.js 3.81 kB -1 B (0%)
build/blob/index.js 665 B +1 B (0%)
build/block-editor/index.js 129 kB +52 B (0%)
build/block-editor/style-rtl.css 11.2 kB +2 B (0%)
build/block-editor/style.css 11.2 kB -1 B (0%)
build/block-library/blocks/navigation/style-rtl.css 205 B -17 B (-8%)
build/block-library/blocks/navigation/style.css 205 B -17 B (-8%)
build/block-library/index.js 150 kB +58 B (0%)
build/block-library/style-rtl.css 8.48 kB -4 B (0%)
build/block-library/style.css 8.48 kB -4 B (0%)
build/block-serialization-default-parser/index.js 1.88 kB +2 B (0%)
build/blocks/index.js 48.1 kB -1 B (0%)
build/components/index.js 170 kB -98 B (0%)
build/compose/index.js 11 kB -3 B (0%)
build/core-data/index.js 15.2 kB -179 B (-1%)
build/data/index.js 8.98 kB -3 B (0%)
build/date/index.js 31.8 kB +2 B (0%)
build/dom/index.js 4.95 kB +1 B (0%)
build/edit-navigation/index.js 11.1 kB +3 B (0%)
build/edit-post/index.js 306 kB +3 B (0%)
build/edit-site/index.js 24.3 kB -114 B (0%)
build/edit-widgets/index.js 26.3 kB -2 B (0%)
build/editor/index.js 42.6 kB -748 B (-2%)
build/format-library/index.js 6.75 kB +10 B (0%)
build/hooks/index.js 2.27 kB +1 B (0%)
build/html-entities/index.js 622 B -1 B (0%)
build/keyboard-shortcuts/index.js 2.54 kB -3 B (0%)
build/media-utils/index.js 5.32 kB +2 B (0%)
build/notices/index.js 1.86 kB -1 B (0%)
build/nux/index.js 3.42 kB -1 B (0%)
build/primitives/index.js 1.43 kB +1 B (0%)
build/redux-routine/index.js 2.84 kB -4 B (0%)
build/reusable-blocks/index.js 2.92 kB -1 B (0%)
build/rich-text/index.js 13.5 kB +8 B (0%)
build/server-side-render/index.js 2.77 kB -1 B (0%)
build/shortcode/index.js 1.7 kB +1 B (0%)
build/url/index.js 3.01 kB +170 B (+6%) 🔍
build/viewport/index.js 1.86 kB +1 B (0%)
build/warning/index.js 1.14 kB -1 B (0%)
build/wordcount/index.js 1.22 kB -1 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/api-fetch/index.js 3.42 kB 0 B
build/autop/index.js 2.83 kB 0 B
build/block-directory/index.js 8.71 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-library/blocks/archives/editor-rtl.css 120 B 0 B
build/block-library/blocks/archives/editor.css 119 B 0 B
build/block-library/blocks/audio/editor-rtl.css 118 B 0 B
build/block-library/blocks/audio/editor.css 118 B 0 B
build/block-library/blocks/audio/style-rtl.css 152 B 0 B
build/block-library/blocks/audio/style.css 152 B 0 B
build/block-library/blocks/block/editor-rtl.css 211 B 0 B
build/block-library/blocks/block/editor.css 211 B 0 B
build/block-library/blocks/button/editor-rtl.css 513 B 0 B
build/block-library/blocks/button/editor.css 513 B 0 B
build/block-library/blocks/button/style-rtl.css 488 B 0 B
build/block-library/blocks/button/style.css 488 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 275 B 0 B
build/block-library/blocks/buttons/editor.css 275 B 0 B
build/block-library/blocks/buttons/style-rtl.css 346 B 0 B
build/block-library/blocks/buttons/style.css 346 B 0 B
build/block-library/blocks/calendar/style-rtl.css 249 B 0 B
build/block-library/blocks/calendar/style.css 249 B 0 B
build/block-library/blocks/categories/editor-rtl.css 135 B 0 B
build/block-library/blocks/categories/editor.css 135 B 0 B
build/block-library/blocks/categories/style-rtl.css 132 B 0 B
build/block-library/blocks/categories/style.css 132 B 0 B
build/block-library/blocks/code/style-rtl.css 152 B 0 B
build/block-library/blocks/code/style.css 152 B 0 B
build/block-library/blocks/columns/editor-rtl.css 239 B 0 B
build/block-library/blocks/columns/editor.css 239 B 0 B
build/block-library/blocks/columns/style-rtl.css 467 B 0 B
build/block-library/blocks/columns/style.css 466 B 0 B
build/block-library/blocks/cover/editor-rtl.css 440 B 0 B
build/block-library/blocks/cover/editor.css 438 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.27 kB 0 B
build/block-library/blocks/cover/style.css 1.27 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 529 B 0 B
build/block-library/blocks/embed/editor.css 529 B 0 B
build/block-library/blocks/embed/style-rtl.css 419 B 0 B
build/block-library/blocks/embed/style.css 419 B 0 B
build/block-library/blocks/file/editor-rtl.css 246 B 0 B
build/block-library/blocks/file/editor.css 245 B 0 B
build/block-library/blocks/file/style-rtl.css 288 B 0 B
build/block-library/blocks/file/style.css 289 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.49 kB 0 B
build/block-library/blocks/freeform/editor.css 2.49 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 692 B 0 B
build/block-library/blocks/gallery/editor.css 693 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.11 kB 0 B
build/block-library/blocks/gallery/style.css 1.11 kB 0 B
build/block-library/blocks/group/editor-rtl.css 364 B 0 B
build/block-library/blocks/group/editor.css 364 B 0 B
build/block-library/blocks/group/style-rtl.css 117 B 0 B
build/block-library/blocks/group/style.css 117 B 0 B
build/block-library/blocks/heading/editor-rtl.css 174 B 0 B
build/block-library/blocks/heading/editor.css 174 B 0 B
build/block-library/blocks/heading/style-rtl.css 137 B 0 B
build/block-library/blocks/heading/style.css 137 B 0 B
build/block-library/blocks/html/editor-rtl.css 324 B 0 B
build/block-library/blocks/html/editor.css 325 B 0 B
build/block-library/blocks/image/editor-rtl.css 738 B 0 B
build/block-library/blocks/image/editor.css 737 B 0 B
build/block-library/blocks/image/style-rtl.css 510 B 0 B
build/block-library/blocks/image/style.css 511 B 0 B
build/block-library/blocks/latest-comments/editor-rtl.css 201 B 0 B
build/block-library/blocks/latest-comments/editor.css 200 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 315 B 0 B
build/block-library/blocks/latest-comments/style.css 315 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 183 B 0 B
build/block-library/blocks/latest-posts/editor.css 183 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 568 B 0 B
build/block-library/blocks/latest-posts/style.css 567 B 0 B
build/block-library/blocks/list/editor-rtl.css 129 B 0 B
build/block-library/blocks/list/editor.css 129 B 0 B
build/block-library/blocks/list/style-rtl.css 127 B 0 B
build/block-library/blocks/list/style.css 127 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 240 B 0 B
build/block-library/blocks/media-text/editor.css 240 B 0 B
build/block-library/blocks/media-text/style-rtl.css 579 B 0 B
build/block-library/blocks/media-text/style.css 577 B 0 B
build/block-library/blocks/more/editor-rtl.css 479 B 0 B
build/block-library/blocks/more/editor.css 479 B 0 B
build/block-library/blocks/navigation-link/editor-rtl.css 438 B 0 B
build/block-library/blocks/navigation-link/editor.css 440 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 747 B 0 B
build/block-library/blocks/navigation-link/style.css 745 B 0 B
build/block-library/blocks/navigation/editor-rtl.css 1.31 kB 0 B
build/block-library/blocks/navigation/editor.css 1.31 kB 0 B
build/block-library/blocks/nextpage/editor-rtl.css 440 B 0 B
build/block-library/blocks/nextpage/editor.css 440 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 161 B 0 B
build/block-library/blocks/paragraph/editor.css 161 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 279 B 0 B
build/block-library/blocks/paragraph/style.css 279 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 255 B 0 B
build/block-library/blocks/post-author/editor.css 255 B 0 B
build/block-library/blocks/post-author/style-rtl.css 229 B 0 B
build/block-library/blocks/post-author/style.css 230 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 293 B 0 B
build/block-library/blocks/post-comments-form/style.css 293 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 187 B 0 B
build/block-library/blocks/post-content/editor.css 187 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 134 B 0 B
build/block-library/blocks/post-excerpt/editor.css 134 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 387 B 0 B
build/block-library/blocks/post-featured-image/editor.css 386 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 149 B 0 B
build/block-library/blocks/post-featured-image/style.css 149 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 119 B 0 B
build/block-library/blocks/preformatted/style.css 119 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 231 B 0 B
build/block-library/blocks/pullquote/editor.css 231 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 359 B 0 B
build/block-library/blocks/pullquote/style.css 359 B 0 B
build/block-library/blocks/query-loop/editor-rtl.css 142 B 0 B
build/block-library/blocks/query-loop/editor.css 141 B 0 B
build/block-library/blocks/query-loop/style-rtl.css 361 B 0 B
build/block-library/blocks/query-loop/style.css 363 B 0 B
build/block-library/blocks/query/editor-rtl.css 210 B 0 B
build/block-library/blocks/query/editor.css 210 B 0 B
build/block-library/blocks/quote/editor-rtl.css 121 B 0 B
build/block-library/blocks/quote/editor.css 121 B 0 B
build/block-library/blocks/quote/style-rtl.css 215 B 0 B
build/block-library/blocks/quote/style.css 214 B 0 B
build/block-library/blocks/rss/editor-rtl.css 245 B 0 B
build/block-library/blocks/rss/editor.css 246 B 0 B
build/block-library/blocks/rss/style-rtl.css 329 B 0 B
build/block-library/blocks/rss/style.css 328 B 0 B
build/block-library/blocks/search/editor-rtl.css 213 B 0 B
build/block-library/blocks/search/editor.css 213 B 0 B
build/block-library/blocks/search/style-rtl.css 384 B 0 B
build/block-library/blocks/search/style.css 386 B 0 B
build/block-library/blocks/separator/editor-rtl.css 151 B 0 B
build/block-library/blocks/separator/editor.css 151 B 0 B
build/block-library/blocks/separator/style-rtl.css 281 B 0 B
build/block-library/blocks/separator/style.css 281 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 547 B 0 B
build/block-library/blocks/shortcode/editor.css 547 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 251 B 0 B
build/block-library/blocks/site-logo/editor.css 251 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 166 B 0 B
build/block-library/blocks/site-logo/style.css 166 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 211 B 0 B
build/block-library/blocks/social-link/editor.css 211 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 749 B 0 B
build/block-library/blocks/social-links/editor.css 749 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.37 kB 0 B
build/block-library/blocks/social-links/style.css 1.37 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 321 B 0 B
build/block-library/blocks/spacer/editor.css 321 B 0 B
build/block-library/blocks/spacer/style-rtl.css 107 B 0 B
build/block-library/blocks/spacer/style.css 107 B 0 B
build/block-library/blocks/subhead/editor-rtl.css 148 B 0 B
build/block-library/blocks/subhead/editor.css 148 B 0 B
build/block-library/blocks/subhead/style-rtl.css 134 B 0 B
build/block-library/blocks/subhead/style.css 134 B 0 B
build/block-library/blocks/table/editor-rtl.css 530 B 0 B
build/block-library/blocks/table/editor.css 530 B 0 B
build/block-library/blocks/table/style-rtl.css 433 B 0 B
build/block-library/blocks/table/style.css 433 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 162 B 0 B
build/block-library/blocks/tag-cloud/editor.css 162 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 145 B 0 B
build/block-library/blocks/tag-cloud/style.css 145 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 644 B 0 B
build/block-library/blocks/template-part/editor.css 645 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 146 B 0 B
build/block-library/blocks/text-columns/editor.css 146 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 209 B 0 B
build/block-library/blocks/text-columns/style.css 209 B 0 B
build/block-library/blocks/verse/editor-rtl.css 118 B 0 B
build/block-library/blocks/verse/editor.css 118 B 0 B
build/block-library/blocks/verse/style-rtl.css 137 B 0 B
build/block-library/blocks/verse/style.css 137 B 0 B
build/block-library/blocks/video/editor-rtl.css 547 B 0 B
build/block-library/blocks/video/editor.css 548 B 0 B
build/block-library/blocks/video/style-rtl.css 241 B 0 B
build/block-library/blocks/video/style.css 241 B 0 B
build/block-library/common-rtl.css 940 B 0 B
build/block-library/common.css 937 B 0 B
build/block-library/editor-rtl.css 9.07 kB 0 B
build/block-library/editor.css 9.07 kB 0 B
build/block-library/theme-rtl.css 789 B 0 B
build/block-library/theme.css 790 B 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/components/style-rtl.css 15.4 kB 0 B
build/components/style.css 15.4 kB 0 B
build/data-controls/index.js 829 B 0 B
build/deprecated/index.js 768 B 0 B
build/dom-ready/index.js 571 B 0 B
build/edit-navigation/style-rtl.css 881 B 0 B
build/edit-navigation/style.css 885 B 0 B
build/edit-post/style-rtl.css 6.47 kB 0 B
build/edit-post/style.css 6.45 kB 0 B
build/edit-site/style-rtl.css 3.91 kB 0 B
build/edit-site/style.css 3.91 kB 0 B
build/edit-widgets/style-rtl.css 3.1 kB 0 B
build/edit-widgets/style.css 3.1 kB 0 B
build/editor/editor-styles-rtl.css 476 B 0 B
build/editor/editor-styles.css 478 B 0 B
build/editor/style-rtl.css 3.84 kB 0 B
build/editor/style.css 3.84 kB 0 B
build/element/index.js 4.63 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/i18n/index.js 3.57 kB 0 B
build/is-shallow-equal/index.js 698 B 0 B
build/keycodes/index.js 1.94 kB 0 B
build/list-reusable-blocks/index.js 3.1 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/plugins/index.js 2.54 kB 0 B
build/priority-queue/index.js 789 B 0 B
build/token-list/index.js 1.27 kB 0 B

compressed-size-action

@ntsekouras ntsekouras force-pushed the try/variations-display-info-lower-level branch from 9e0381d to e39ff8b Compare December 4, 2020 09:01
@ntsekouras
Copy link
Contributor Author

This is a comment of @talldan in another draft PR of mine for this problem and I'm just putting it here to have the discussions.

@ntsekouras This reminds me of a discussion some of us had about the legacy widget block. That block is similar to embeds in that it has variations for the different types of widgets represented. A subset of widgets are 'reference widgets', which can only be used once in a 'post'. The challenge was making the block supports multiple setting work for variations, which was pretty much impossible without being able to reliably identify the variation used to create the block:

This is the issue - #25494

@ntsekouras ntsekouras force-pushed the try/variations-display-info-lower-level branch from e39ff8b to 508c304 Compare December 4, 2020 09:21
@ntsekouras ntsekouras changed the title Yet Another experiment for block variations - No reviews please :) Display Block Information by matching block variations Dec 4, 2020
@ntsekouras ntsekouras self-assigned this Dec 4, 2020
@ntsekouras ntsekouras added [Feature] Block Variations Block variations, including introducing new variations and variations as a feature [Package] Components /packages/components labels Dec 4, 2020
@ntsekouras
Copy link
Contributor Author

@talldan I think if this approach goes on, you could make use of variationMatcher.

With an addition of a property (variationMatcher) in Blocks settings. This optional property is a function to match block variations. It doesn't check dynamically all block properties to try to find a match, because in many cases like it doesn't make sense. An example is embed block where we can have changed the responsive attribute, so a match would not be found.

Copy link
Contributor

@mcsf mcsf left a comment

Choose a reason for hiding this comment

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

I like that we're exploring this, but it's a delicate thing to get right. I've left some comments, but I still haven't decided which approach I prefer (e.g. new dedicated selectors, refactor base getBlockType selectors, let certain UI components manage it, etc.).

I also haven't commented on the extension of the Variations API with variationMatcher, but I'd like us to weigh it against different options (e.g. blockType.variationAttributeName, blockType.variations[0].isActive(), etc.).

packages/block-editor/src/components/index.js Outdated Show resolved Hide resolved
packages/blocks/src/store/selectors.js Outdated Show resolved Hide resolved
packages/blocks/src/store/selectors.js Outdated Show resolved Hide resolved
packages/block-editor/src/components/block-card/index.js Outdated Show resolved Hide resolved
@ntsekouras
Copy link
Contributor Author

Thanks for starting to look at it and sharing your feedback @gziolo and @mcsf - really appreciate it. This is a problem that we would need to solve (matching variation) and by discussing it, will find the best approach!

I know that the current status of the PR (as of writing this comment) is not the best, but it's a start :) I'd like some feedback from others as well that have worked in related things. --cc @talldan, @youknowriad , @noahtallen

@ntsekouras ntsekouras force-pushed the try/variations-display-info-lower-level branch 2 times, most recently from 09be23e to faa27e5 Compare December 11, 2020 10:19
@gziolo
Copy link
Member

gziolo commented Dec 11, 2020

I also haven't commented on the extension of the Variations API with variationMatcher, but I'd like us to weigh it against different options (e.g. blockType.variationAttributeName, blockType.variations[0].isActive(), etc.).

I personally lean towards blockType.variations[0].isActive(). This API is specific to variations so it might be difficult to explain in documentation when added as a top-level block type property. While it might create some code duplication when added to individual variations but it's perfectly fine to use a shared function. Besides, it gives the opportunity to select which variations should be considered for the check and even it can be customized per individual item.

I was also wondering, whether the getBlockDisplayInformation selector still necessary now that there is a hook that consolidates the same functionality? @youknowriad, can you share some recommendations in terms of performance as it needs to use data from two stores: core/blocks and core/block-editor. It would be also recomputed every time a block attribute changes, a block type or its block variations.

@ntsekouras
Copy link
Contributor Author

I have created a separate PR to refactor BlockSwitcher there, to make this one easier to review: #27674.

I personally lean towards blockType.variations[0].isActive(). This API is specific to variations so it might be difficult to explain in documentation when added as a top-level block type property. While it might create some code duplication when added to individual variations but it's perfectly fine to use a shared function. Besides, it gives the opportunity to select which variations should be considered for the check and even it can be customized per individual item.

I believe that the main use case of matching block variations doesn't need much customization per variation. I can't think of an example that could utilize that, but of course there could be...

What seems to me important though is:

This API is specific to variations so it might be difficult to explain in documentation when added as a top-level block type property.

So I'm going to make it per variation.

@ntsekouras ntsekouras force-pushed the try/variations-display-info-lower-level branch from b880062 to 324d6a7 Compare December 15, 2020 11:52
@ntsekouras
Copy link
Contributor Author

I was also wondering, whether the getBlockDisplayInformation selector still necessary now that there is a hook that consolidates the same functionality?

I removed the selector. I'll need to revisit BlockTitle though because we have some logic there that needs the blockType and attributes for getBlockLabel. I haven't decided how to handle this yet...

@ntsekouras ntsekouras added [Package] Block editor /packages/block-editor and removed [Package] Components /packages/components labels Dec 15, 2020
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Nice work, I think it's close 👍🏻

There are some things to clarify:

  • what should be the final API for isActive matcher added to the block variation
  • how should useMatchingVariationInformation be called, the type proposed is WPBlockDisplayInformation so it needs some alignment, it feels like useBlockDisplayInformation would better express intent
  • we should measure the performance implications of useMatchingVariationInformation, at the moment it probably will recompute every time core/block-editor changes which would be good, we should ensure it doesn't re-render when other stores change.

@ntsekouras ntsekouras force-pushed the try/variations-display-info-lower-level branch from 2b880d7 to 1f83290 Compare December 16, 2020 17:18
@ntsekouras
Copy link
Contributor Author

what should be the final API for isActive matcher added to the block variation

Changed like this per suggestion: #27469 (comment)

how should useMatchingVariationInformation be called, the type proposed is WPBlockDisplayInformation so it needs some alignment, it feels like useBlockDisplayInformation would better express intent

Makes sense and changed it to useBlockDisplayInformation

@ntsekouras ntsekouras force-pushed the try/variations-display-info-lower-level branch from 248db30 to 1114567 Compare December 17, 2020 14:09
@ntsekouras ntsekouras force-pushed the try/variations-display-info-lower-level branch from 0c7a7c3 to 8501b34 Compare December 18, 2020 12:07
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

This PR is in excellent shape now so I left mostly nitpicks. Thank you for all iterations. I'm personally satisfied with the last revision proposed. I still need to test this functionality although I anticipate it being only a formal step because e2e tests added cover that 👍🏻

I will wait for your response before doing the final check and approve this PR.

ntsekouras and others added 7 commits December 23, 2020 09:04
Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
Co-authored-by: Greg Ziółkowski <grzegorz@gziolo.pl>
@ntsekouras
Copy link
Contributor Author

Thanks for all the help here @gziolo! I addressed all the feedback and it's waiting for the final check to land 🎉 😄

@gziolo gziolo added [Type] New API New API to be used by plugin developers or package users. Needs Dev Note Requires a developer note for a major WordPress release cycle labels Dec 23, 2020
@gziolo
Copy link
Member

gziolo commented Dec 23, 2020

There is one issue I discovered, the icon and its label in the block toolbar is coming from the block type rather than from the variation:

Screen Shot 2020-12-23 at 13 58 58

Screen Shot 2020-12-23 at 14 00 29

In all other places, I'm aware of, everything works perfectly fine.

I did some testing with the profiler I couldn't notice any unnecessary re-renders in the block card when I was changing unrelated block attributes.

Stats from the performance e2e tests look good as well:

Screen Shot 2020-12-23 at 13 55 09

Screen Shot 2020-12-23 at 13 55 14

@ntsekouras
Copy link
Contributor Author

ntsekouras commented Dec 23, 2020

There is one issue I discovered, the icon and its label in the block toolbar is coming from the block type rather than from the variation:

Thanks for testing performance impact for this! 💯

@gziolo I have it mind and below is the reason. I will create a follow up as soon as this one lands. Sounds okay with you?

From my PR description:

To make use of the new hook and handle Transforms icon(in toolbar), I need to make BlockSwitcher a function component which is handled in this PR: #27674 to make reviewing easier.
The icon in BlockSwitcher will be handled in a follow up after the refactoring PR lands.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

🚢

@ntsekouras ntsekouras merged commit 4b14897 into master Dec 23, 2020
@ntsekouras ntsekouras deleted the try/variations-display-info-lower-level branch December 23, 2020 13:31
@github-actions github-actions bot added this to the Gutenberg 9.7 milestone Dec 23, 2020
@noisysocks noisysocks mentioned this pull request Jan 28, 2021
9 tasks
@youknowriad youknowriad removed the Needs Dev Note Requires a developer note for a major WordPress release cycle label Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Variations Block variations, including introducing new variations and variations as a feature [Package] Block editor /packages/block-editor [Type] New API New API to be used by plugin developers or package users.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants