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

Media & Text: Turn Stack on mobile toggle on by default #14364

Merged
merged 1 commit into from
Sep 23, 2019
Merged

Media & Text: Turn Stack on mobile toggle on by default #14364

merged 1 commit into from
Sep 23, 2019

Conversation

AmirS
Copy link
Contributor

@AmirS AmirS commented Mar 10, 2019

Description

Fixes #14281.

This PR updates the Media & Text block to be responsive by default.
When new Media & Text block is added, "Stack on mobile" toggle is set to on by default.

How has this been tested?

The Media and Text block is updated to use true as a default value for isStackedOnMobile block attribute.
Core__media-text*** fixtures have been regenerated to include is-stacked-on-mobile class name for the Media & Text block elements.

Screenshots

Screenshot 2019-03-10 at 22 57 33

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Can you clarify if or where a discussion took place leading to this suggested change?

@@ -64,7 +64,7 @@ const blockAttributes = {
},
isStackedOnMobile: {
type: 'boolean',
default: false,
default: true,
Copy link
Member

Choose a reason for hiding this comment

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

Unless I'm mistaken, this would be considered a breaking change, and would invalidate existing Media & Text blocks.

See also: https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-deprecation/

@marekhrabe
Copy link
Contributor

This originated in #14281. I have a feeling it cannot be this easy to update the default, as it will indeed invalidate blocks. Can we make migration somehow simply for this?

Also, I think that when the stacking becomes default, we should implement it also as a default in CSS and only add a classname when NOT stacking (opposite logic of the current one). Does that make sense?

@jorgefilipecosta
Copy link
Member

jorgefilipecosta commented Mar 27, 2019

Hi @AmirS thank you for working on this PR.
I added a commit with the required deprecation logic.
To test it I pasted (in this branch) the following code in the code editor created using the master branch:

<!-- wp:media-text {"mediaType":"image"} -->
<div class="wp-block-media-text alignwide"><figure class="wp-block-media-text__media"><img src="https://s.w.org/images/home/screen-themes.png?3" alt=""/></figure><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…","fontSize":"large"} -->
<p class="has-large-font-size">Test</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:media-text -->

<!-- wp:media-text {"align":"full","mediaPosition":"right","mediaType":"image"} -->
<div class="wp-block-media-text alignfull has-media-on-the-right"><figure class="wp-block-media-text__media"><img src="https://s.w.org/images/home/screen-themes.png?3" alt=""/></figure><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…","fontSize":"large"} -->
<p class="has-large-font-size">Test</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:media-text -->

<!-- wp:media-text {"align":"","mediaPosition":"right","mediaType":"image","isStackedOnMobile":true} -->
<div class="wp-block-media-text has-media-on-the-right is-stacked-on-mobile"><figure class="wp-block-media-text__media"><img src="https://s.w.org/images/home/screen-themes.png?3" alt=""/></figure><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…","fontSize":"large"} -->
<p class="has-large-font-size">Test</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:media-text -->

<!-- wp:media-text {"align":"full","mediaPosition":"right","mediaType":"image","isStackedOnMobile":true} -->
<div class="wp-block-media-text alignfull has-media-on-the-right is-stacked-on-mobile"><figure class="wp-block-media-text__media"><img src="https://s.w.org/images/home/screen-themes.png?3" alt=""/></figure><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…","fontSize":"large"} -->
<p class="has-large-font-size">Test</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:media-text -->

The blocks were migrated successfully and kept the stack on mobile setting they had.

Also, I think that when the stacking becomes default, we should implement it also as a default in CSS and only add a classname when NOT stacking (opposite logic of the current one). Does that make sense?

Unfortunately, it is not possible to implement it as the default on CSS, without changing all the existing blocks that set stack on mobile as false to be stacked on mobile. That is breaking change as we are changing the look of existing blocks even if the user does not open them on the editor.
We may discuss this after, or check if someone has an idea to mitigate this problem. I think we can add some kind of migration but if the user never opens&saves the post the post will be set to stacked on mobile.

I think this PR should be ready.

@gziolo gziolo added [Block] Media & Text Affects the Media & Text Block [Type] Bug An existing feature does not function as intended and removed [Type] Bug An existing feature does not function as intended labels Apr 10, 2019
@AmirS AmirS closed this May 3, 2019
@melchoyce
Copy link
Contributor

Hey, why was this PR closed?

@AmirS AmirS reopened this May 17, 2019
@gziolo gziolo added First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement. labels Jun 3, 2019
@paaljoachim
Copy link
Contributor

Hey @AmirS

Could you give us a status update on this PR? Let us know what we can do to help move this PR onward. Is this PR ready for a final review? Thanks.

@AmirS
Copy link
Contributor Author

AmirS commented Aug 27, 2019

Yes, after the required deprecation logic added by @jorgefilipecosta, this PR should be ready for a review.

@noisysocks noisysocks added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 29, 2019
@noisysocks
Copy link
Member

Hey @AmirS, the changes here look good but the branch needs to be rebased with the latest changes in master.

@jorgefilipecosta jorgefilipecosta removed the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Sep 20, 2019
@jorgefilipecosta
Copy link
Member

Hi @noisysocks, the conflicts this PR were really huge and across all the files. I reapplied the change from master following the same logic and regenerated all the media&text fixtures, it seems to be working well and is ready for a review.

Copy link
Member

@jorgefilipecosta jorgefilipecosta 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 seems ready, let's merge it. If there is any further comment please add them here and we will iterate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Media & Text Affects the Media & Text Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media & Text: Turn "Stack on mobile" toggle on by default
9 participants