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

[RNMobile] Add "Set as Featured Image" Button to Image Block (iOS Only) #31415

Conversation

SiobhyB
Copy link
Contributor

@SiobhyB SiobhyB commented May 3, 2021

Partial fix for: wordpress-mobile/gutenberg-mobile#1011

gutenberg-mobile: wordpress-mobile/gutenberg-mobile#3450
WordPress-iOS: wordpress-mobile/WordPress-iOS#16426

The main PR for the branch this individual PR will be merged into, add/featured-functionality-to-image-block-ios, can be found here: #31345

Description

Building on the work done in #31347, this PR will add a Set as Featured button to the image block's settings, with the purpose being to make it simpler for users to set a featured image within the post's editor. Users will also be able to Remove as Featured directly from the block's settings.

How has this been tested?

Test Case 1: General Flow

To start with, the general flow for setting a featured image via the image block on a post without an existing image is as follows.
  • In the app, navigate to HomeBlog Posts to create a new blog post, one which doesn't already have a featured image set.
  • Add a new image block, and upload an image to it.
  • Tap the image block's cog/gear icon to access its settings.
  • Observe the new Set as Featured button at the bottom of the settings and tap it.
  • Verify that you see a confirmation message about the newly set featured image and that the block now has a Featured banner overlaying it.

Test Case 2: "Replace Existing" Flow

It's also possible for users to replace an existing featured image via the following flow.
  • Add a new image block to the post and upload a second image to it.
  • Again, tap the image block's cog/gear icon to access its settings.
  • Tap the Set as Featured button at the bottom of the settings and tap it.
  • A dialog should appear to inform you that the post already has a featured image, with an option to Cancel or confirm your wish to Replace.
  • Tap Cancel to confirm it works as expected, to dismiss the action.
  • Go through steps two through four again and this time tap Replace.
  • Verify that you see a confirmation message about the newly set featured image and that the block now has a Featured banner overlaying it. The banner should no longer overlay the previous featured image.

Test Case 3: "Editor Loads" Flow

Next, we should verify that a **Remove as Featured** option appears when a post with a featured image is first loaded. To test this, follow these steps.
  • Verify that a featured image has been set on the post and tap the back button.
  • Return to the post's editor by tapping on it from the post list screen.
  • Verify that the post's featured image has a Featured banner overlaying it. Tap the cog/gear icon to then confirm the option to Remove as Featured appears.

Test Case 4: "Post Settings" Flow

The image block should be updated to reflect whether its image is featured or not even when the featured image is set via the general Post Settings flow.
  • Tap the three icons to the upper right of the post editor to access Post Settings.
  • Tap existing featured image and then Remove.
  • Tap the back button to confirm that the Featured banner has been removed from the featured image, as expected. Tap the cog/gear icon to then confirm the option to Set as Featured appears.
  • Return to the Post Settings screen and set a new featured image.
  • Tap the back button. If the new featured image hasn't already been added to the editor via an image block, add it.
  • Confirm that the Featured banner displays overlays the correct image and that Remove as Featured appears in its settings.

Test Case 5: "Replace in Image Block" Flow

Finally, it's possible to replace an image directly within the image block's settings. We need to verify that the featured settings update as expected depending on the image that's chosen for an image block.
  • Select any image block that is flagged with the Featured banner.
  • Tap the edit icon to the upper right and then Replace.
  • Replace with any image that isn't the post's featured image.
  • Verify that the Featured banner is removed from the block when the new image uploads and that the Set as Featured button appears in the block's settings.
  • Go through the steps to replace the block's image again, this time pick the post's featured image.
  • Verify that the Featured banner appears again and that the Remove as Featured button appears in the block's settings.

Screenshots

Set as Featured Image Remove as Featured Image
Replace Dialog Confirmation Dialog

Types of changes

This PR introduces a new feature (non-breaking change which adds functionality). The feature it introduces is a Set as Featured button in the image block's setting, which enables a user to either set an image as featured or remove it as featured. A high-level overview of the code changes involved is as follows:

  • This PR relies on the getSetFeaturedButton component deployed in the Android version of this PR ([RNMobile] Add "Set as Featured Image" Button to Image Block (Android Only) #28854) to display a Set as Featured or a Remove as Featured button, depending on whether isFeaturedImage is true or not. Further details around the logic behind isFeaturedImage can also be found in that PR.
  • setFeaturedImage will be called when the button is tapped, this function utilizes another function named gutenbergDidRequestToSetFeaturedImage to send an image's media ID over the bridge when a request is made to either set a new featured image (in which case the media ID is that of the selected image) or to remove an existing featured image (in which case the media ID is zero).
  • When the featured image is changed, the native side will update Gutenberg via the featuredImageIdNativeUpdated listener, keeping the native apps as our main source of truth when it comes to confirming the change to the post's featured image ID.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • 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 (please manually search all *.native.js files for terms that need renaming or removal).

Siobhan added 7 commits April 29, 2021 17:27
…ImageId() over the bridge

gutenbergFeaturedImageId() will be used to gather the initial ID of a post's featured image when the editor first loads in iOS.
"border-radius" doesn't function as intended on iOS devices without use of "overflow: hidden".
…er.swift

This is to align the code in the demo file with the code in GutenbergBridgeDataSource, so that it runs as expected.
@SiobhyB SiobhyB added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label May 3, 2021
@SiobhyB SiobhyB changed the base branch from trunk to add/featured-functionality-to-image-block-ios May 3, 2021 09:20
@github-actions
Copy link

github-actions bot commented May 3, 2021

Size Change: 0 B

Total Size: 1.04 MB

ℹ️ View Unchanged
Filename Size Change
build/a11y/index.min.js 1.12 kB 0 B
build/annotations/index.min.js 2.93 kB 0 B
build/api-fetch/index.min.js 2.44 kB 0 B
build/autop/index.min.js 2.28 kB 0 B
build/blob/index.min.js 672 B 0 B
build/block-directory/index.min.js 6.61 kB 0 B
build/block-directory/style-rtl.css 989 B 0 B
build/block-directory/style.css 990 B 0 B
build/block-editor/index.min.js 119 kB 0 B
build/block-editor/style-rtl.css 13.5 kB 0 B
build/block-editor/style.css 13.5 kB 0 B
build/block-library/blocks/archives/editor-rtl.css 61 B 0 B
build/block-library/blocks/archives/editor.css 60 B 0 B
build/block-library/blocks/archives/style-rtl.css 65 B 0 B
build/block-library/blocks/archives/style.css 65 B 0 B
build/block-library/blocks/audio/editor-rtl.css 58 B 0 B
build/block-library/blocks/audio/editor.css 58 B 0 B
build/block-library/blocks/audio/style-rtl.css 112 B 0 B
build/block-library/blocks/audio/style.css 112 B 0 B
build/block-library/blocks/audio/theme-rtl.css 125 B 0 B
build/block-library/blocks/audio/theme.css 125 B 0 B
build/block-library/blocks/block/editor-rtl.css 161 B 0 B
build/block-library/blocks/block/editor.css 161 B 0 B
build/block-library/blocks/button/editor-rtl.css 475 B 0 B
build/block-library/blocks/button/editor.css 474 B 0 B
build/block-library/blocks/button/style-rtl.css 603 B 0 B
build/block-library/blocks/button/style.css 602 B 0 B
build/block-library/blocks/buttons/editor-rtl.css 315 B 0 B
build/block-library/blocks/buttons/editor.css 315 B 0 B
build/block-library/blocks/buttons/style-rtl.css 375 B 0 B
build/block-library/blocks/buttons/style.css 375 B 0 B
build/block-library/blocks/calendar/style-rtl.css 208 B 0 B
build/block-library/blocks/calendar/style.css 208 B 0 B
build/block-library/blocks/categories/editor-rtl.css 84 B 0 B
build/block-library/blocks/categories/editor.css 83 B 0 B
build/block-library/blocks/categories/style-rtl.css 79 B 0 B
build/block-library/blocks/categories/style.css 79 B 0 B
build/block-library/blocks/code/style-rtl.css 90 B 0 B
build/block-library/blocks/code/style.css 90 B 0 B
build/block-library/blocks/code/theme-rtl.css 131 B 0 B
build/block-library/blocks/code/theme.css 131 B 0 B
build/block-library/blocks/columns/editor-rtl.css 190 B 0 B
build/block-library/blocks/columns/editor.css 190 B 0 B
build/block-library/blocks/columns/style-rtl.css 422 B 0 B
build/block-library/blocks/columns/style.css 422 B 0 B
build/block-library/blocks/cover/editor-rtl.css 644 B 0 B
build/block-library/blocks/cover/editor.css 646 B 0 B
build/block-library/blocks/cover/style-rtl.css 1.22 kB 0 B
build/block-library/blocks/cover/style.css 1.23 kB 0 B
build/block-library/blocks/embed/editor-rtl.css 486 B 0 B
build/block-library/blocks/embed/editor.css 486 B 0 B
build/block-library/blocks/embed/style-rtl.css 401 B 0 B
build/block-library/blocks/embed/style.css 400 B 0 B
build/block-library/blocks/embed/theme-rtl.css 124 B 0 B
build/block-library/blocks/embed/theme.css 124 B 0 B
build/block-library/blocks/file/editor-rtl.css 301 B 0 B
build/block-library/blocks/file/editor.css 300 B 0 B
build/block-library/blocks/file/frontend.min.js 773 B 0 B
build/block-library/blocks/file/style-rtl.css 255 B 0 B
build/block-library/blocks/file/style.css 255 B 0 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB 0 B
build/block-library/blocks/freeform/editor.css 2.44 kB 0 B
build/block-library/blocks/gallery/editor-rtl.css 704 B 0 B
build/block-library/blocks/gallery/editor.css 705 B 0 B
build/block-library/blocks/gallery/style-rtl.css 1.06 kB 0 B
build/block-library/blocks/gallery/style.css 1.06 kB 0 B
build/block-library/blocks/gallery/theme-rtl.css 122 B 0 B
build/block-library/blocks/gallery/theme.css 122 B 0 B
build/block-library/blocks/group/editor-rtl.css 160 B 0 B
build/block-library/blocks/group/editor.css 160 B 0 B
build/block-library/blocks/group/style-rtl.css 57 B 0 B
build/block-library/blocks/group/style.css 57 B 0 B
build/block-library/blocks/group/theme-rtl.css 93 B 0 B
build/block-library/blocks/group/theme.css 93 B 0 B
build/block-library/blocks/heading/editor-rtl.css 152 B 0 B
build/block-library/blocks/heading/editor.css 152 B 0 B
build/block-library/blocks/heading/style-rtl.css 76 B 0 B
build/block-library/blocks/heading/style.css 76 B 0 B
build/block-library/blocks/home-link/style-rtl.css 259 B 0 B
build/block-library/blocks/home-link/style.css 259 B 0 B
build/block-library/blocks/html/editor-rtl.css 281 B 0 B
build/block-library/blocks/html/editor.css 281 B 0 B
build/block-library/blocks/image/editor-rtl.css 729 B 0 B
build/block-library/blocks/image/editor.css 727 B 0 B
build/block-library/blocks/image/style-rtl.css 481 B 0 B
build/block-library/blocks/image/style.css 485 B 0 B
build/block-library/blocks/image/theme-rtl.css 124 B 0 B
build/block-library/blocks/image/theme.css 124 B 0 B
build/block-library/blocks/latest-comments/style-rtl.css 281 B 0 B
build/block-library/blocks/latest-comments/style.css 282 B 0 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B 0 B
build/block-library/blocks/latest-posts/editor.css 137 B 0 B
build/block-library/blocks/latest-posts/style-rtl.css 529 B 0 B
build/block-library/blocks/latest-posts/style.css 529 B 0 B
build/block-library/blocks/list/style-rtl.css 63 B 0 B
build/block-library/blocks/list/style.css 63 B 0 B
build/block-library/blocks/media-text/editor-rtl.css 176 B 0 B
build/block-library/blocks/media-text/editor.css 176 B 0 B
build/block-library/blocks/media-text/style-rtl.css 492 B 0 B
build/block-library/blocks/media-text/style.css 489 B 0 B
build/block-library/blocks/more/editor-rtl.css 434 B 0 B
build/block-library/blocks/more/editor.css 434 B 0 B
build/block-library/blocks/navigation-link/editor-rtl.css 633 B 0 B
build/block-library/blocks/navigation-link/editor.css 634 B 0 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B 0 B
build/block-library/blocks/navigation-link/style.css 94 B 0 B
build/block-library/blocks/navigation/editor-rtl.css 1.55 kB 0 B
build/block-library/blocks/navigation/editor.css 1.55 kB 0 B
build/block-library/blocks/navigation/frontend.min.js 2.86 kB 0 B
build/block-library/blocks/navigation/style-rtl.css 1.63 kB 0 B
build/block-library/blocks/navigation/style.css 1.63 kB 0 B
build/block-library/blocks/nextpage/editor-rtl.css 395 B 0 B
build/block-library/blocks/nextpage/editor.css 395 B 0 B
build/block-library/blocks/page-list/editor-rtl.css 310 B 0 B
build/block-library/blocks/page-list/editor.css 311 B 0 B
build/block-library/blocks/page-list/style-rtl.css 240 B 0 B
build/block-library/blocks/page-list/style.css 240 B 0 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B 0 B
build/block-library/blocks/paragraph/editor.css 157 B 0 B
build/block-library/blocks/paragraph/style-rtl.css 247 B 0 B
build/block-library/blocks/paragraph/style.css 248 B 0 B
build/block-library/blocks/post-author/editor-rtl.css 209 B 0 B
build/block-library/blocks/post-author/editor.css 209 B 0 B
build/block-library/blocks/post-author/style-rtl.css 183 B 0 B
build/block-library/blocks/post-author/style.css 184 B 0 B
build/block-library/blocks/post-comments-form/style-rtl.css 140 B 0 B
build/block-library/blocks/post-comments-form/style.css 140 B 0 B
build/block-library/blocks/post-comments/style-rtl.css 360 B 0 B
build/block-library/blocks/post-comments/style.css 359 B 0 B
build/block-library/blocks/post-content/editor-rtl.css 139 B 0 B
build/block-library/blocks/post-content/editor.css 139 B 0 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B 0 B
build/block-library/blocks/post-excerpt/editor.css 73 B 0 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B 0 B
build/block-library/blocks/post-excerpt/style.css 69 B 0 B
build/block-library/blocks/post-featured-image/editor-rtl.css 338 B 0 B
build/block-library/blocks/post-featured-image/editor.css 338 B 0 B
build/block-library/blocks/post-featured-image/style-rtl.css 141 B 0 B
build/block-library/blocks/post-featured-image/style.css 141 B 0 B
build/block-library/blocks/post-template/editor-rtl.css 100 B 0 B
build/block-library/blocks/post-template/editor.css 99 B 0 B
build/block-library/blocks/post-template/style-rtl.css 379 B 0 B
build/block-library/blocks/post-template/style.css 380 B 0 B
build/block-library/blocks/post-title/style-rtl.css 60 B 0 B
build/block-library/blocks/post-title/style.css 60 B 0 B
build/block-library/blocks/preformatted/style-rtl.css 103 B 0 B
build/block-library/blocks/preformatted/style.css 103 B 0 B
build/block-library/blocks/pullquote/editor-rtl.css 183 B 0 B
build/block-library/blocks/pullquote/editor.css 183 B 0 B
build/block-library/blocks/pullquote/style-rtl.css 318 B 0 B
build/block-library/blocks/pullquote/style.css 318 B 0 B
build/block-library/blocks/pullquote/theme-rtl.css 169 B 0 B
build/block-library/blocks/pullquote/theme.css 169 B 0 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B 0 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B 0 B
build/block-library/blocks/query-pagination/editor-rtl.css 270 B 0 B
build/block-library/blocks/query-pagination/editor.css 262 B 0 B
build/block-library/blocks/query-pagination/style-rtl.css 168 B 0 B
build/block-library/blocks/query-pagination/style.css 168 B 0 B
build/block-library/blocks/query-title/editor-rtl.css 86 B 0 B
build/block-library/blocks/query-title/editor.css 86 B 0 B
build/block-library/blocks/query/editor-rtl.css 131 B 0 B
build/block-library/blocks/query/editor.css 132 B 0 B
build/block-library/blocks/quote/style-rtl.css 169 B 0 B
build/block-library/blocks/quote/style.css 169 B 0 B
build/block-library/blocks/quote/theme-rtl.css 221 B 0 B
build/block-library/blocks/quote/theme.css 221 B 0 B
build/block-library/blocks/rss/editor-rtl.css 201 B 0 B
build/block-library/blocks/rss/editor.css 202 B 0 B
build/block-library/blocks/rss/style-rtl.css 290 B 0 B
build/block-library/blocks/rss/style.css 290 B 0 B
build/block-library/blocks/search/editor-rtl.css 211 B 0 B
build/block-library/blocks/search/editor.css 211 B 0 B
build/block-library/blocks/search/style-rtl.css 359 B 0 B
build/block-library/blocks/search/style.css 362 B 0 B
build/block-library/blocks/search/theme-rtl.css 64 B 0 B
build/block-library/blocks/search/theme.css 64 B 0 B
build/block-library/blocks/separator/editor-rtl.css 99 B 0 B
build/block-library/blocks/separator/editor.css 99 B 0 B
build/block-library/blocks/separator/style-rtl.css 251 B 0 B
build/block-library/blocks/separator/style.css 251 B 0 B
build/block-library/blocks/separator/theme-rtl.css 172 B 0 B
build/block-library/blocks/separator/theme.css 172 B 0 B
build/block-library/blocks/shortcode/editor-rtl.css 512 B 0 B
build/block-library/blocks/shortcode/editor.css 512 B 0 B
build/block-library/blocks/site-logo/editor-rtl.css 440 B 0 B
build/block-library/blocks/site-logo/editor.css 441 B 0 B
build/block-library/blocks/site-logo/style-rtl.css 154 B 0 B
build/block-library/blocks/site-logo/style.css 154 B 0 B
build/block-library/blocks/site-tagline/editor-rtl.css 87 B 0 B
build/block-library/blocks/site-tagline/editor.css 87 B 0 B
build/block-library/blocks/site-title/editor-rtl.css 85 B 0 B
build/block-library/blocks/site-title/editor.css 85 B 0 B
build/block-library/blocks/social-link/editor-rtl.css 164 B 0 B
build/block-library/blocks/social-link/editor.css 165 B 0 B
build/block-library/blocks/social-links/editor-rtl.css 800 B 0 B
build/block-library/blocks/social-links/editor.css 799 B 0 B
build/block-library/blocks/social-links/style-rtl.css 1.34 kB 0 B
build/block-library/blocks/social-links/style.css 1.34 kB 0 B
build/block-library/blocks/spacer/editor-rtl.css 308 B 0 B
build/block-library/blocks/spacer/editor.css 308 B 0 B
build/block-library/blocks/spacer/style-rtl.css 48 B 0 B
build/block-library/blocks/spacer/style.css 48 B 0 B
build/block-library/blocks/table/editor-rtl.css 478 B 0 B
build/block-library/blocks/table/editor.css 478 B 0 B
build/block-library/blocks/table/style-rtl.css 480 B 0 B
build/block-library/blocks/table/style.css 480 B 0 B
build/block-library/blocks/table/theme-rtl.css 188 B 0 B
build/block-library/blocks/table/theme.css 188 B 0 B
build/block-library/blocks/tag-cloud/editor-rtl.css 118 B 0 B
build/block-library/blocks/tag-cloud/editor.css 118 B 0 B
build/block-library/blocks/tag-cloud/style-rtl.css 94 B 0 B
build/block-library/blocks/tag-cloud/style.css 94 B 0 B
build/block-library/blocks/template-part/editor-rtl.css 551 B 0 B
build/block-library/blocks/template-part/editor.css 550 B 0 B
build/block-library/blocks/template-part/theme-rtl.css 101 B 0 B
build/block-library/blocks/template-part/theme.css 101 B 0 B
build/block-library/blocks/term-description/editor-rtl.css 90 B 0 B
build/block-library/blocks/term-description/editor.css 90 B 0 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B 0 B
build/block-library/blocks/text-columns/editor.css 95 B 0 B
build/block-library/blocks/text-columns/style-rtl.css 166 B 0 B
build/block-library/blocks/text-columns/style.css 166 B 0 B
build/block-library/blocks/verse/style-rtl.css 87 B 0 B
build/block-library/blocks/verse/style.css 87 B 0 B
build/block-library/blocks/video/editor-rtl.css 569 B 0 B
build/block-library/blocks/video/editor.css 570 B 0 B
build/block-library/blocks/video/style-rtl.css 173 B 0 B
build/block-library/blocks/video/style.css 173 B 0 B
build/block-library/blocks/video/theme-rtl.css 124 B 0 B
build/block-library/blocks/video/theme.css 124 B 0 B
build/block-library/common-rtl.css 1.26 kB 0 B
build/block-library/common.css 1.26 kB 0 B
build/block-library/editor-rtl.css 9.69 kB 0 B
build/block-library/editor.css 9.69 kB 0 B
build/block-library/index.min.js 145 kB 0 B
build/block-library/reset-rtl.css 514 B 0 B
build/block-library/reset.css 515 B 0 B
build/block-library/style-rtl.css 10.2 kB 0 B
build/block-library/style.css 10.2 kB 0 B
build/block-library/theme-rtl.css 692 B 0 B
build/block-library/theme.css 693 B 0 B
build/block-serialization-default-parser/index.min.js 1.3 kB 0 B
build/block-serialization-spec-parser/index.min.js 3.06 kB 0 B
build/blocks/index.min.js 47.3 kB 0 B
build/components/index.min.js 180 kB 0 B
build/components/style-rtl.css 16.2 kB 0 B
build/components/style.css 16.2 kB 0 B
build/compose/index.min.js 10.2 kB 0 B
build/core-data/index.min.js 12.2 kB 0 B
build/customize-widgets/index.min.js 9.98 kB 0 B
build/customize-widgets/style-rtl.css 1.45 kB 0 B
build/customize-widgets/style.css 1.45 kB 0 B
build/data-controls/index.min.js 829 B 0 B
build/data/index.min.js 7.22 kB 0 B
build/date/index.min.js 31.8 kB 0 B
build/deprecated/index.min.js 739 B 0 B
build/dom-ready/index.min.js 576 B 0 B
build/dom/index.min.js 4.62 kB 0 B
build/edit-navigation/index.min.js 14 kB 0 B
build/edit-navigation/style-rtl.css 3.08 kB 0 B
build/edit-navigation/style.css 3.08 kB 0 B
build/edit-post/classic-rtl.css 454 B 0 B
build/edit-post/classic.css 454 B 0 B
build/edit-post/index.min.js 58.6 kB 0 B
build/edit-post/style-rtl.css 7.04 kB 0 B
build/edit-post/style.css 7.03 kB 0 B
build/edit-site/index.min.js 26 kB 0 B
build/edit-site/style-rtl.css 4.75 kB 0 B
build/edit-site/style.css 4.75 kB 0 B
build/edit-widgets/index.min.js 16 kB 0 B
build/edit-widgets/style-rtl.css 3.49 kB 0 B
build/edit-widgets/style.css 3.5 kB 0 B
build/editor/index.min.js 38.6 kB 0 B
build/editor/style-rtl.css 3.91 kB 0 B
build/editor/style.css 3.9 kB 0 B
build/element/index.min.js 3.44 kB 0 B
build/escape-html/index.min.js 739 B 0 B
build/format-library/index.min.js 5.68 kB 0 B
build/format-library/style-rtl.css 637 B 0 B
build/format-library/style.css 639 B 0 B
build/hooks/index.min.js 1.76 kB 0 B
build/html-entities/index.min.js 628 B 0 B
build/i18n/index.min.js 3.73 kB 0 B
build/is-shallow-equal/index.min.js 709 B 0 B
build/keyboard-shortcuts/index.min.js 1.74 kB 0 B
build/keycodes/index.min.js 1.43 kB 0 B
build/list-reusable-blocks/index.min.js 2.07 kB 0 B
build/list-reusable-blocks/style-rtl.css 629 B 0 B
build/list-reusable-blocks/style.css 628 B 0 B
build/media-utils/index.min.js 3.08 kB 0 B
build/notices/index.min.js 1.07 kB 0 B
build/nux/index.min.js 2.31 kB 0 B
build/nux/style-rtl.css 718 B 0 B
build/nux/style.css 716 B 0 B
build/plugins/index.min.js 1.99 kB 0 B
build/primitives/index.min.js 1.03 kB 0 B
build/priority-queue/index.min.js 791 B 0 B
build/react-i18n/index.min.js 924 B 0 B
build/redux-routine/index.min.js 2.82 kB 0 B
build/reusable-blocks/index.min.js 2.56 kB 0 B
build/reusable-blocks/style-rtl.css 225 B 0 B
build/reusable-blocks/style.css 225 B 0 B
build/rich-text/index.min.js 10.6 kB 0 B
build/server-side-render/index.min.js 1.64 kB 0 B
build/shortcode/index.min.js 1.68 kB 0 B
build/token-list/index.min.js 847 B 0 B
build/url/index.min.js 1.95 kB 0 B
build/viewport/index.min.js 1.28 kB 0 B
build/warning/index.min.js 1.13 kB 0 B
build/widgets/index.min.js 6.48 kB 0 B
build/widgets/style-rtl.css 722 B 0 B
build/widgets/style.css 722 B 0 B
build/wordcount/index.min.js 1.24 kB 0 B

compressed-size-action

Siobhan added 2 commits May 3, 2021 14:47
…bergViewController

This update ensures the function conforms to the pattern set out for it in GutenbergBridgeDelegate
@SiobhyB SiobhyB force-pushed the add/set-as-featured-button-ios branch from 219d68b to 0bcc7ca Compare May 21, 2021 14:32
@SiobhyB SiobhyB force-pushed the add/set-as-featured-button-ios branch from b804297 to bd7bfa0 Compare May 30, 2021 19:52
@SiobhyB SiobhyB requested a review from guarani June 1, 2021 08:44
@guarani
Copy link
Contributor

guarani commented Jun 1, 2021

Testing wordpress-mobile/WordPress-iOS@1a8758a on iPhone 11 Pro Max simulator.

Test Case 1: General Flow

  • The "Set as Feature Image" option is off-screen for me on iPhone 11 Pro Max simulator when using an image that had a link set, so its discoverability seems low in certain situations (which reminded me of this post 😄).

  • The small edit/replace button that was previously shown inside an image canvas is now shown outside. I have to check trunk to see if this is specific to this branch or is a change or regression on trunk. It looks like this bug isn't present on trunk:

    This branch trunk
    Screen Shot 2021-06-01 at 15 36 21 Screen Shot 2021-06-01 at 18 03 43
  • When the message "Set/Removed as Feature Image" is shown for a few seconds, just before it's removed, it seems to flash momentarily. I'm not sure if this is a symptom of something being called twice for example, so I just want to flag it for you (at 0:05s in the video below):

    See video
    Screen.Recording.2021-06-01.at.15.45.48.mov
  • I noticed that featured images didn't load in post previews on private sites, but it has nothing to do with this PR and I filed an issue here: Featured images not loading when viewing posts on a private site wordpress-mobile/WordPress-iOS#16607

Test Case 2: "Replace Existing" Flow

  • The bottom (default) button in the action sheet that's shown when replacing a featured image should be "Cancel" At the moment, both options shown are "Replace"

    See screenshot Screen Shot 2021-06-01 at 16 34 24
  • Looking at the screenshot above, I'm not sure if the action sheet's title should be a question (i.e. "Replace?"). Looking at other parts of the app, I notice the edit/replace button's action sheet doesn't use a question in its title. An alternative could be "Featured image already set" (or "Featured image options"). I'm fine leaving it as-is, just wanted to share the thought.

  • When a post already has a featured image set via Post Settings and the user goes to set a different image via the Image block and is presented with the replace action sheet, I think some users might be confused because they don't see any other image in the post marked as Featured. This could happen for users who aren't already familiar with Post Settings (e.g. they haven't used featured images in Post Settings before, or they've only ever set featured images on the web, etc). One option here would be to make the replace action sheet title explain where the image is already set. This is more of an enhancement (not a blocker for this PR), but to give an example, the title could be:

    • "Featured image already set in Post Settings" if image was set via Post Settings, or
    • "Featured image already set" if image was set via an Image block
  • "Feature Image" in the "Set/Removed as Feature Image" messages maybe should be lowercase i.e. "Set/Removed as feature image" (it's up to you, I'm open to what you think is best here).

Test Case 3: "Editor Loads" Flow

No new feedback.

Test Case 4: "Post Settings" Flow

No new feedback.

Test Case 5: "Replace in Image Block" Flow

  • Here things worked as described in the test case, but my expectation was that replacing a featured image would update the post's featured image to the new image. In this scenario I can think of three options:
    A. Replacing the featured image removes the featured image from the post
    B. Replacing the featured image leaves the featured image in place in Post Settings (this is the current behavior)
    C. Replacing the featured image updates the post's featured image
    Intuitively, I thought option C would be how this would work. Maybe I'd associated the "Featured" banner too closely to the Image block itself, when it's in fact an attribute of the image. Again, not a blocker, just wanted to flag this.

@SiobhyB, great work here and I appreciate the easy to ready testing instructions 👍. I haven't had a chance to look at the code but will do that next.

Following feedback, the getSetFeaturedButton function has been re-named to getFeaturedButtonPanel for clarity.
@SiobhyB
Copy link
Contributor Author

SiobhyB commented Jun 2, 2021

Thanks so much for your thorough review, Paul! I'll go ahead to work through it all and address feedback from each "test case" in a separate comment.

@SiobhyB
Copy link
Contributor Author

SiobhyB commented Jun 2, 2021

Response to Feedback from Test Case 1

The "Set as Feature Image" option is off-screen for me on iPhone 11 Pro Max simulator when using an image that had a link set, so its discoverability seems low in certain situations (which reminded me of this post 😄).

Ah, thank you for sharing that post! I enjoyed the writer's perspective and it reminded me of similar encounters with users, who weren't aware of certain features due to a lack of scroll indicators. As the issue can be found on all BottomSheets with overflowing content, it seems like this may be larger than this specific PR. I've gone ahead to create an enhancement request at #32409.

Let me know if you think any more action is required around this specific PR.

The small edit/replace button that was previously shown inside an image canvas is now shown outside. It looks like this bug isn't present on trunk.

I wasn't able to reproduce an issue specific to this branch. Did you test using the same image, with the same size set?

I do see that the edit/replace button appears outside of the image in cases where the size is set to anything other than Full Size (via the block's settings), but this was true in trunk in my testing also.

When the message "Set/Removed as Feature Image" is shown for a few seconds, just before it's removed, it seems to flash momentarily. I'm not sure if this is a symptom of something being called twice for example, so I just want to flag it for you (at 0:05s in the video below)

I'm able to replicate the flickering but having a difficult time tracking down why it's happening. I'm only able to replicate it when a featured image is set/removed straight away (i.e. the replace dialog isn't used), so I wonder if it's something related to the BottomSheet dismissal. 🤔 I'll keep exploring.

@SiobhyB
Copy link
Contributor Author

SiobhyB commented Jun 2, 2021

Response to Feedback from Test Case 2

The bottom (default) button in the action sheet that's shown when replacing a featured image should be "Cancel" At the moment, both options shown are "Replace"

This was fixed in wordpress-mobile/WordPress-iOS@02db104, thank you so much for spotting that!

Looking at the screenshot above, I'm not sure if the action sheet's title should be a question (i.e. "Replace?"). Looking at other parts of the app, I notice the edit/replace button's action sheet doesn't use a question in its title. An alternative could be "Featured image already set" (or "Featured image options"). I'm fine leaving it as-is, just wanted to share the thought.

I appreciate the extra context around how other titles work in the app. I like Featured Image Already Set (using title case), I've gone ahead to use that wording in and updated in wordpress-mobile/WordPress-iOS@8063237. I've also updated the Android side in wordpress-mobile/WordPress-Android@1eb55fa.

When a post already has a featured image set via Post Settings and the user goes to set a different image via the Image block and is presented with the replace action sheet, I think some users might be confused because they don't see any other image in the post marked as Featured.

I agree that there may be some confusion around which image is set as featured. Thomas mentioned this in a design review, also, and I've opened an enhancement request at #30410. Although I'll be focusing on other areas of code after this project, I've added it to a list that I hope to get to someday, perhaps a future HACK week when I've built up my knowledge a bit more. :)

"Feature Image" in the "Set/Removed as Feature Image" messages maybe should be lowercase i.e. "Set/Removed as feature image" (it's up to you, I'm open to what you think is best here).

I initially viewed these as headings of sorts, which is why I went with title case, but I think that's a bit of a debatable classification and you're right that title case isn't really appropriate, especially as other notices don't use title case in the app. I've gone ahead to update this for iOS in wordpress-mobile/WordPress-iOS@7e7a291 and for Android in wordpress-mobile/WordPress-Android@c1f6842.

@SiobhyB
Copy link
Contributor Author

SiobhyB commented Jun 2, 2021

Response to Feedback from Test Case 5

Here things worked as described in the test case, but my expectation was that replacing a featured image would update the post's featured image to the new image. In this scenario I can think of three options:
A. Replacing the featured image removes the featured image from the post
B. Replacing the featured image leaves the featured image in place in Post Settings (this is the current behavior)
C. Replacing the featured image updates the post's featured image
Intuitively, I thought option C would be how this would work. Maybe I'd associated the "Featured" banner too closely to the Image block itself, when it's in fact an attribute of the image. Again, not a blocker, just wanted to flag this.

This is really useful feedback that matches some other internal chatter, thank you! I'll keep monitoring feedback like this and consider tracking it via a new GitHub issue if it continues to be a theme. 🙇‍♀️

@guarani
Copy link
Contributor

guarani commented Jun 2, 2021

Response to Feedback from Test Case 1

Ah, thank you for sharing that post! I enjoyed the writer's perspective and it reminded me of similar encounters with users, who weren't aware of certain features due to a lack of scroll indicators. As the issue can be found on all BottomSheets with overflowing content, it seems like this may be larger than this specific PR. I've gone ahead to create an enhancement request at #32409.

Let me know if you think any more action is required around this specific PR.

Thanks for making that issue! I agree it isn't specific to this PR so happy to see it left out for now.

I wasn't able to reproduce an issue specific to this branch. Did you test using the same image, with the same size set?

I do see that the edit/replace button appears outside of the image in cases where the size is set to anything other than Full Size (via the block's settings), but this was true in trunk in my testing also.

I'm having trouble with the iOS build at the moment, but once that's done I'll come back and test this to make sure I see the same thing on this branch and on trunk.

I'm able to replicate the flickering but having a difficult time tracking down why it's happening. I'm only able to replicate it when a featured image is set/removed straight away (i.e. the replace dialog isn't used), so I wonder if it's something related to the BottomSheet dismissal. 🤔 I'll keep exploring.

I've seen some minor quirks with that notice. For example, if you delete a couple of blocks one-after-the-other, the "Block removed" notices get queued up which is probably unexpected (at least in that scenario). I haven't seen this particular flickering issue anywhere else though.

Response to Feedback from Test Case 2

This was fixed in wordpress-mobile/WordPress-iOS@02db104, thank you so much for spotting that!

No worries!

I appreciate the extra context around how other titles work in the app. I like Featured Image Already Set (using title case), I've gone ahead to use that wording in and updated in wordpress-mobile/WordPress-iOS@8063237. I've also updated the Android side in wordpress-mobile/WordPress-Android@1eb55fa.

Sounds good!

I agree that there may be some confusion around which image is set as featured. Thomas mentioned this in a design review, also, and I've opened an enhancement request at #30410. Although I'll be focusing on other areas of code after this project, I've added it to a list that I hope to get to someday, perhaps a future HACK week when I've built up my knowledge a bit more. :)

Looks great, thanks for creating that issue.

I initially viewed these as headings of sorts, which is why I went with title case, but I think that's a bit of a debatable classification and you're right that title case isn't really appropriate, especially as other notices don't use title case in the app. I've gone ahead to update this for iOS in wordpress-mobile/WordPress-iOS@7e7a291 and for Android in wordpress-mobile/WordPress-Android@c1f6842.

🙇

Response to Feedback from Test Case 5

This is really useful feedback that matches some other internal chatter, thank you! I'll keep monitoring feedback like this and consider tracking it via a new GitHub issue if it continues to be a theme. 🙇‍♀️

Glad to know I'm not alone raising that feedback.
Thanks again @SiobhyB.

@SiobhyB SiobhyB force-pushed the add/set-as-featured-button-ios branch from 761af27 to ad77029 Compare June 3, 2021 10:59
Siobhan added 2 commits June 3, 2021 12:28
With this PR, the featured button will work on iOS and this const will no longer be needed.
@SiobhyB SiobhyB marked this pull request as ready for review June 3, 2021 17:43
@SiobhyB
Copy link
Contributor Author

SiobhyB commented Jun 3, 2021

I've seen some minor quirks with that notice. For example, if you delete a couple of blocks one-after-the-other, the "Block removed" notices get queued up which is probably unexpected (at least in that scenario). I haven't seen this particular flickering issue anywhere else though.

Thanks for this extra context! I did some testing and am also able to reproduce some quirkiness with the notice on Android. If I'm not able to find a straightforward fix as part of this PR, I might lean towards creating a separate issue. But I'll spend a bit more time experimenting tomorrow first. 🙇‍♀️

@guarani
Copy link
Contributor

guarani commented Jun 3, 2021

I'm having trouble with the iOS build at the moment, but once that's done I'll come back and test this to make sure I see the same thing on this branch and on trunk.

I think your comment earlier was spot on, it has to do with the Image size setting and has nothing to do with this PR.

@guarani
Copy link
Contributor

guarani commented Jun 4, 2021

I gave this another test today and spotted one issue: Sometimes the Featured Image section in Post Settings displays an "Upload Failed. Tap for options." message when I select and then deselect featured images. Then when I retry from the Post Settings screen, it loads an image from a previous post (not the image from the post I'm currently on):

retry-diff-image.mov

An image can't be set as featured unless it's been successfully uploaded to the site's media library, but the 'canImageBeFeatured' check didn't account for this.

A temporary negative ID is given to images that are in progress or fail to upload. With this commit, a check for whether an image's ID is more than zero is added to 'canImageBeFeatured' in order to account for those times.

Note, 'this.state.isUploadInProgress' isn't used, as it doesn't account for times where an upload fails. Instead, a ID check acts as a catch all.
@SiobhyB
Copy link
Contributor Author

SiobhyB commented Jun 4, 2021

@guarani, thank you for spotting that! I think what might be happening is this:

  • An image is given a temporary negative ID while it's in the process of uploading e.g. -2838582747
  • As the featured button is available while an image is uploading, it's technically possible to send that negative ID back to the JS side.
  • If the negative ID is sent back to the JS side then it'd cause some issues, including the wrong image displayed in Post Settings.

I've added a check to ensure the button only displays when an image's ID is greater than zero in 60d205c as a way to avoid this.

That said, I have some uncertainty as it seems like the image in your video is fully uploaded and I had a bit of trouble reliably replicating. I was able to replicate, but only following a lot of trial and error with forcing an upload to fail while in progress (by turning the WiFi off).

I'm not able to replicate the issue any more but, if you're still able to replicate on your side even with the latest change, would you be able to add the following logging within the render() function in the image block's edit.native.js file for me?

console.log( "Image's ID: " + attributes.id );
console.log( "Featured image's ID: " + featuredImageId );

I'd be interested to know what the output is after you first click the Set as Featured button and then again after clicking the Remove as Featured button. (Ideally, both values should be the same after you first click the button, with featuredImageId changing to zero after you remove it.)

@guarani guarani self-requested a review June 24, 2021 21:51
Copy link
Contributor

@guarani guarani left a comment

Choose a reason for hiding this comment

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

Testing wordpress-mobile/WordPress-iOS@8f47364 on iPad 8th gen:

  • Test Case 1: General Flow
  • Test Case 2: "Replace Existing" Flow
    On iPad, cancel buttons are not rendered (which is expected I think) so tapping outside the action sheet works instead of cancelling.
  • Test Case 3: "Editor Loads" Flow
  • Test Case 4: "Post Settings" Flow
    With regard to setting a featured image via Post Settings and then adding the image to the editor via the image block, the featured image banner only shows up if I add the image from the WP Media Library, not the device. I think this is expected though, since adding an image from the device is treated as a different image to the one that's in the WP Media Library, even if they're the same image.
  • Test Case 5: "Replace in Image Block" Flow
    Same applies here where replacing an image only restores the featured image banner if the image is re-added via the WP Media Library.

I don't think any of the above are issues, just wanted to note them here.
Looks great and works great, thanks @SiobhyB!

@SiobhyB SiobhyB merged commit 5ac3d4e into add/featured-functionality-to-image-block-ios Jun 25, 2021
@SiobhyB SiobhyB deleted the add/set-as-featured-button-ios branch June 25, 2021 09:17
SiobhyB added a commit that referenced this pull request Aug 2, 2021
…ctly from Image Block (iOS Only) (#31345)

* Update CHANGELOG.md with feature details

* [RNMobile] Add Featured Banner to Image Block (iOS Only) (#31347)

Add a "featured" banner that overlays the image block on iOS devices.

* [RNMobile] Add "Set as Featured Image" Button to Image Block (iOS Only) (#31415)

Add "Set as Featured Image" Button to Image Block

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants