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

Improve media & text block on IE. #10812

Merged
merged 1 commit into from
Oct 11, 2019
Merged

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Oct 19, 2018

Description

Fixes: #11577
Grid layout on ie has some special needs.
This PR applies a series of changes to get to a point where the main block problems on IE are mostly solved.
The autoprefixer configuration was updated to support grid prefixes.

The remaining problem on IE is that on the frontend the media & content always appear at 50% width. The way to solve this problem would require that we set an IE-specific inline style on the markup of the block. So we would be transferring more bytes over the wire for all the users to fix the problem in this browser, so I opted to leave this change out. In my option, the resizing can be seen as a progressive enhancement.

Screenshots:

Before:

screenshot 2019-02-14 at 14 19 19

After:
screenshot 2019-02-14 at 14 18 09

@jorgefilipecosta jorgefilipecosta force-pushed the fix/media-text-block-on-ie branch from 26b99d2 to dd6f103 Compare October 26, 2018 15:23
@jorgefilipecosta jorgefilipecosta changed the title WIP Improve media & text block on IE. Improve media & text block on IE. Oct 26, 2018
@jorgefilipecosta jorgefilipecosta requested a review from a team October 26, 2018 20:45
grid-area: resizer;
-ms-grid-column: 1;
-ms-grid-column-span: 2;
-ms-grid-row: 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding this mse specific styles here, can we just enable grid: true in autoprefixer config?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @youknowriad, I agree using the autoprefixer is an awesome idea and makes the code simpler.
I did some tests, and the template areas we had were not working even with the autoprefixer, setting columns spans using grid-column: 1 / -1; also did not work but using grid-column: 1 / span 2; works.
It looks like with this changes to the CSS and using the autoprefixer things are working fine in more modern browsers and in IE11, without having IE prefixes around the code.
Thank you for the suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the change to the autoprefixer config in the changes? Is it already enabled?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I missed a stash on the change, the problem was corrected.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/media-text-block-on-ie branch 4 times, most recently from dc9dfa8 to 66ed56e Compare October 29, 2018 15:42
@Soean Soean added the [Block] Media & Text Affects the Media & Text Block label Oct 31, 2018
@gziolo gziolo added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Feb 7, 2019
@gziolo
Copy link
Member

gziolo commented Feb 7, 2019

@jorgefilipecosta this branch has merge conflicts and needs to be refreshed. It seems like it never to reviewed. Can you bring it up to date and remove Stale label which I'm applying to make review and triage process easier?

@jorgefilipecosta
Copy link
Member Author

Hi @gziolo this PR was rebased and updated to work with the new "Media & Text" functionalities like the stack on mobile.

@jorgefilipecosta jorgefilipecosta added Browser Issues Issues or PRs that are related to browser specific problems and removed [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. labels Feb 14, 2019
@gziolo gziolo added this to the 5.2 (Gutenberg) milestone Feb 14, 2019
aduth
aduth previously requested changes Apr 24, 2019
const style = {
gridTemplateColumns: 'right' === mediaPosition ? `auto ${ widthString }` : `${ widthString } auto`,
gridTemplateColumns,
msGridColumns: gridTemplateColumns,
Copy link
Member

Choose a reason for hiding this comment

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

Note that style attributes must be whitelisted. This was missed for grid-template-columns previously, and can result in invalidated blocks for non-administrator users.

See also: https://core.trac.wordpress.org/ticket/46597

We should probably add a filter to include -ms-grid-columns for the safe_style_css set in the plugin, and propose a complementing upstream Trac ticket once this is merged.

https://developer.wordpress.org/reference/hooks/safe_style_css/

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @aduth, this PR is not changing the block save function/markup of the block. At the time (before 5.0 release) in talks with @mtias it was discussed if we should add an IE specific style to the block inline styles and we decided not to do it. The disadvantage is that on the website frontend the image always appears at 50% width, on the backend we add the correct style so it appears on the correct width.

Given that we are not adding -ms-grid-columns on the save function I don't think there is a need to update filters compared to what we are already doing on the patches available at https://core.trac.wordpress.org/ticket/46597.

Copy link
Member

Choose a reason for hiding this comment

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

this PR is not changing the block save function/markup of the block

Ah, you're right. Sorry, I missed that.

I guess it makes me wonder then what's the purported benefit, if we're only solving the issue in the editor, but not on the front-end. To me, it would seem the latter would be the more important anyways. At the very least, should it not be marked as fixing #11577 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, the block does not work in IE (front-end and editor), the media element and the content don't event appear side by side. This PR fixes most of the problems on the front end (in the editor fixes all of them). The layout appears side by side the vertical-align options work, the background position change works, the only thing that does not work is the resizing on the front end (e.g: things appear always with the default 50% width), compared to the current state is a big improvement. Issue #11577 says "Media & Text block is not aligning in IE 11" and I guess that problem is fixed the alignments work as expected, maybe we can close and add a comment specifying that just the resizing functionality does not work on the front end.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/media-text-block-on-ie branch from 1d26630 to 0ef748a Compare April 29, 2019 14:39
@gziolo gziolo removed this from the 5.6 (Gutenberg) milestone May 6, 2019
@tyrann0us
Copy link
Contributor

@jorgefilipecosta, what's the status here? Thanks!
CC @aduth, @gziolo

@jorgefilipecosta jorgefilipecosta force-pushed the fix/media-text-block-on-ie branch from 0ef748a to 6c7efc1 Compare May 13, 2019 12:12
@jorgefilipecosta
Copy link
Member Author

Hi @tyrann0us, this rebased and updated. It is waiting for a review in order to be merged.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/media-text-block-on-ie branch from 6c7efc1 to 566d358 Compare May 28, 2019 08:17
@jorgefilipecosta jorgefilipecosta force-pushed the fix/media-text-block-on-ie branch from 566d358 to dc87785 Compare October 9, 2019 15:48
@jorgefilipecosta
Copy link
Member Author

This PR was updated and should be ready just needs a review.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/media-text-block-on-ie branch from dc87785 to 61b1925 Compare October 10, 2019 15:38
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Seems to work well in my testing.

Squashed commits:
[48c530fcb] Improve media&text block on IE.
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 Browser Issues Issues or PRs that are related to browser specific problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media & Text block is not aligning in IE 11
7 participants