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

Google Calendar block: Fix full width support #14835

Merged
merged 2 commits into from
Mar 18, 2020

Conversation

apeatling
Copy link
Member

@apeatling apeatling commented Feb 27, 2020

Make sure that the Google Calendar block widths match in the editor and front end, and that full and wide widths are supported correctly.

Fixes #14823

Testing instructions:

  • Add the Google Calendar block, and embed a calendar. Example:
    <iframe src="https://calendar.google.com/calendar/embed?src=tl4njqffodltemv385vnifrjadm345g2%40import.calendar.google.com&ctz=America%2FVancouver" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>
  • Modify the alignment of the block to full width.
  • Save the changes and look at the block on the front end and confirm it is full width (edge to edge).
  • Try the left and right alignment options and confirm the width of the block matches in the front end and the editor.

Note: on some themes (e.g. Twenty Twenty) the left/right positioning of this block in the front end might overflow outside of the viewport because of its min-width. Eventually we decided that having a readable calendar on most themes is better than having a squished calendar on all themes. (See discussion in the PR comments)

Proposed changelog entry for your changes:

  • None

@apeatling apeatling added [Type] Bug When a feature is broken and / or not performing as intended [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Feb 27, 2020
@apeatling apeatling requested review from pento and a team February 27, 2020 23:39
@apeatling apeatling self-assigned this Feb 27, 2020
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello apeatling! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D39574-code before merging this PR. Thank you!

@apeatling apeatling added this to the 8.4 milestone Feb 28, 2020
@scruffian
Copy link
Member

This looks good, and works as expected. However I can't see how the height attribute is used; it doesn't seem to be working. Is that expected?

@apeatling
Copy link
Member Author

apeatling commented Mar 2, 2020

This looks good, and works as expected. However I can't see how the height attribute is used; it doesn't seem to be working. Is that expected?

It seems to set a default initial height of the iframe in the editor. I originally removed it, but in the editor the height of the iframe was always collapsed with no way to override this with CSS. It worked on the front end however.

scruffian
scruffian previously approved these changes Mar 3, 2020
Copy link
Member

@scruffian scruffian left a comment

Choose a reason for hiding this comment

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

The height attribute seems to be working now. LGTM...

Copy link
Contributor

@glendaviesnz glendaviesnz left a comment

Choose a reason for hiding this comment

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

The removal of the min-width on the iframe in the editor causes the calendar to squash to a smaller width on left and right align than on centre. Dave initially picked this up here.

Screen Shot 2020-03-03 at 3 13 48 PM

I vaguely remember a discussion about this, apologies if there was and I didn't pipe up then.

@apeatling
Copy link
Member Author

@davemart-in Thoughts on the widths of left and right alignment? I do think it needs to be narrower here to allow for content to sit beside it and not also be squished:

Screen Shot 2020-03-03 at 1 36 37 PM

@davemart-in
Copy link
Contributor

@glendaviesnz here's where it was discussed previously. Originating here.

@davemart-in
Copy link
Contributor

@apeatling We added a height property to the map block. Should we just add a width property/option in the sidebar here? That way the customer could set the width to whatever works best for their page.

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Block] Google Calendar and removed [Status] Needs Cherry-Pick [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Mar 4, 2020
@jetpackbot
Copy link

jetpackbot commented Mar 4, 2020

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: April 7, 2020.
Scheduled code freeze: March 31, 2020

Generated by 🚫 dangerJS against 386b658

@apeatling
Copy link
Member Author

@davemart-in We can do that, I think the issue in my mind is how does this interact with the "full-width" and "wide" alignment options? Does it just override this width setting?

@davemart-in
Copy link
Contributor

@apeatling good question.

Would it make sense to only show the width option when the alignment is left, right, or center. Or would that be too confusing do you think?

Another option would be to fix the width to 100% when in full-width and wide mode and disable the control. Then maybe add a line under it saying "Full-width alignment applied", or something like that.

@Copons
Copy link
Contributor

Copons commented Mar 4, 2020

There are a couple of weird behaviours going on. 🤔

I don't understand why we set the height as block attribute, when there's no way to change it.
Might as well have it in a constant instead, and keep the block footprint lighter?

How the heck is the iframe width calculated when float aligned? 😮
It seems to be always 260px to me...
I've tried adding a width="600" to the iframe in the PHP side, and not only it was still rendered 260px wide, but it also changed the height to 260! 😅
Changing the container's width doesn't seem to do anything as well...

@glendaviesnz
Copy link
Contributor

How the heck is the iframe width calculated when float aligned? 😮

Yeh, I couldn't for the life of me work out where that float width was being inherited from, but this does override it - 1334560#diff-6c3f07277cda5eda687f141e3ef5e805

@glendaviesnz
Copy link
Contributor

I don't understand why we set the height as block attribute, when there's no way to change it.

It is extracted from the embed code as the user can specify custom height and width when setting up the embed - but we should also have an option for the user to change this once the block is added.

@apeatling
Copy link
Member Author

apeatling commented Mar 5, 2020

I think we can add back the min width only when the block is aligned left and right. I pretty skeptical that adding a width control is a worthy time investment though. I think we could just set the min width to 50% when aligned left/right, and support full/wide width and move on. If we hear from users that they want to change this, then look at more fine grained control.

@apeatling
Copy link
Member Author

All of the default themes provide default styles for alignleft and alignright floats that causes this to be really problematic. Not to mention themes like TwentyTwenty put floats in their own column with a restricted width.

@scruffian
Copy link
Member

This opens of the question of how much control we should give users to do things that might not always work well. Its hard to know where to draw the line between giving them the freedom to break stuff and preventing them from creating bad designs.

@matticbot
Copy link
Contributor

apeatling, Your synced wpcom patch D39574-code has been updated.

@Copons Copons added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Mar 10, 2020
@github-actions
Copy link
Contributor

Howdy! The Jetpack team has disappeared for a few days to a secret island lair to concoct new ways to make Jetpack one hundred billion percent better. As a result, your Pull Request may not be reviewed right away. Do not worry, we will be back next week to look at your work! Thank you for your understanding.

@davemart-in
Copy link
Contributor

I think we can add back the min width only when the block is aligned left and right.

I'd vote to do this and then call it good.

@Copons
Copy link
Contributor

Copons commented Mar 11, 2020

I think we can add back the min width only when the block is aligned left and right.

I'd vote to do this and then call it good.

@davemart-in It was unclear in my previous comment, but I believe this to be very hard to develop.
The problem is that themes treat floaty-aligned blocks in unpredictable ways: some move them outside of the content, some resize them responsively, some calculate the position from the content width, etc.
We can add a min width to the block, but we might break some themes in the process. 😞

@davemart-in
Copy link
Contributor

We can add a min width to the block, but we might break some themes in the process. 😞

The alternative is that the calendar will look broken by default on ALL themes when the alignment is set to left or right.

calendar-squished

This calendar just looks broken to me. I can't imagine that anyone would want this to show up like this on their site.

Themes can always override the min-width if they want.

@Copons
Copy link
Contributor

Copons commented Mar 11, 2020

@davemart-in 🤔 makes sense.

I've tried with min-width: 420px (which is roughly the size where an event popup is fully visible in the embed), and this is how it looks at different sizes on Twenty Nineteen and Twenty Twenty:

1920 1280 700
Screenshot 2020-03-11 at 14 06 33 Screenshot 2020-03-11 at 14 06 41 Screenshot 2020-03-11 at 14 06 50
Screenshot 2020-03-11 at 14 05 22 Screenshot 2020-03-11 at 14 05 31 Screenshot 2020-03-11 at 14 05 56

Unfortunately Twenty Twenty's float alignment is 290px wide, so at some screen sizes the calendar would end up outside, but there's not much we can do there.
I think this is good enough though, should I commit?

@davemart-in
Copy link
Contributor

Aside: Odd that there would be more text content visible in the 700px resolution vs. the 1280px resolution:

text

I think this is good enough though, should I commit?

I think this is better than the alternative of not setting a min-width, so yes, let's commit it.

Thank you!

@matticbot
Copy link
Contributor

apeatling, Your synced wpcom patch D39574-code has been updated.

@apeatling
Copy link
Member Author

@Copons Thanks for digging into and following up on this one! 🥇

@apeatling
Copy link
Member Author

@Copons With your commit I think this is ready for final review, right?

@Copons
Copy link
Contributor

Copons commented Mar 16, 2020

@Copons With your commit I think this is ready for final review, right?

@apeatling Yes I believe so

Copy link
Member

@scruffian scruffian left a comment

Choose a reason for hiding this comment

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

Let's merge this 🚢

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Mar 17, 2020
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This works well for me, it should be good to merge!

@Copons Copons dismissed glendaviesnz’s stale review March 18, 2020 11:32

Lots changed since this review 🙂

@Copons Copons merged commit c163451 into master Mar 18, 2020
@Copons Copons deleted the fix/google-calendar-full-width branch March 18, 2020 11:33
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Mar 18, 2020
jeherve added a commit that referenced this pull request Mar 20, 2020
jeherve added a commit that referenced this pull request Mar 31, 2020
* Initial changelog entry

* Changelog: add #14904

* Changelog: add #14910

* Changelog: add #14913

* Changelog: add #14916

* Changelog: add #14922

* Changelog: add #14924

* Changelog: add #14925

* Changelog: add #14928

* Changelog: add #14840

* Changelog: add #14841

* Changelog: add #14842

* Changelog: add #14826

* Changelog: add #14835

* Changelog: add #14859

* Changelog: add #14884

* Changelog: add #14888

* Changelog: add #14817

* Changelog: add #14814

* Changelog: add #14819

* Changelog;: add #14797

* Changelog: add #14798

* Changelog: add #14802

* Changelog: add #13676

* Changelog: add #13744

* Changelog: add #13777

* Changelog: add #14446

* Changelog: add #14739

* Changelog: add #14770

* Changelog: add #14784

* Changelog: add #14897

* Changelog: add #14898

* Changelog: add #14968

* Changelog: add #14985

* Changelog: add #15044

* Changelog: add #15052

* Update to remove Podcast since it remains in Beta

* Changelog: add #14803

* Changelog: add #15028

* Changelog: add #15065

* Changelog:add #14886

* Changelog: add #15118

* Changelog: add #14990

* Changelog: add #14528

* Changelog: add #15120

* Changelog: add #15126

* Changelog: add #15049

* Chanegelog: add #14852

* Changelog: add #15090

* Changelog: add #15138

* Changelog: add #15124

* Changelog:add #15055

* Changelog: add #15017

* Changelog: add #15109

* Changelog: add #15145

* Changelog:add #15096

* Changelog:add #15153

* Changelog: add #15133

* Changelog: add #14960

* Changelog: add #15127

* Changelog: add #15056

* Copy current changelog to changelog archive.

* Clarify changelog description
if ( empty( $url ) ) {
return;
}

if ( class_exists( 'Jetpack_AMP_Support' ) && \Jetpack_AMP_Support::is_amp_request() ) {
return sprintf(
'<div class="%1$s"><amp-iframe src="%2$s" frameborder="0" style="border:0" scrolling="no" width="%3$d" height="%4$d" sandbox="allow-scripts allow-same-origin" layout="responsive"></amp-iframe></div>',
'<div class="%1$s"><amp-iframe src="%2$s" frameborder="0" style="border:0" scrolling="no" height="%3$d" sandbox="allow-scripts allow-same-origin" layout="responsive"></amp-iframe></div>',
Copy link
Contributor

Choose a reason for hiding this comment

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

This change appears to have broken Google Calendar on AMP pages, since there is no width defined, and the layout was not changed from responsive to fixed-height. Opened PR to fix in #17251.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Google Calendar Touches WP.com Files [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google Calendar block: full width option not working properly
9 participants