material icon indicating copy to clipboard operation
material copied to clipboard

Layout system does not work with Safari.

Open mikol opened this issue 11 years ago • 28 comments

Commit: e2148f1

User Agents

Mozilla/5.0 (iPhone; CPU iPhone OS 10_9_5 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.3.18 (KHTML, like Gecko) Version/7.1.3 Safari/537.85.12

Reproducing

  1. Create a container with three items and layout attributes layout="row" layout-wrap.
  2. Each item should include the flex attribute and a min-width: 320px CSS declaration.
  3. View the page with Safari on iOS (I used 8.x on both a real and simulated iPhone 6) or OS X.

Actual Results

The items do not wrap as expected. See the screenshot below, in which it is clear that the items are still laid out left-to-right rather than stacked top-to-bottom as expected for layout-wrap at this viewport width. I suspect this has something to do with the way that autoprefixer is configured – i.e., contrary to claims that recent Safari versions (starting with 7 on iOS) implement the final version of the flexbox layout specification, Safari is not 100% compatible and angular-material.css is missing the vendor prefixes required by Safari’s actual implementation.

2015-02-28-09-42-30

Expected Results

The items stack top-to-bottom as expected on Android Chrome.

2015-02-28-09-49-01

mikol avatar Feb 28 '15 18:02 mikol

CodePen

mikol avatar Mar 02 '15 04:03 mikol

It looks like Safari does not use min-width to calculate flex-basis. In order to work around this issue, we need to override the flex-basis imparted by the [flex] { flex: 1; } declaration (which uses the shorthand and assigns flex-basis: auto by default). Our declaration must use !important or be more specific:

.item {
  ...
}

[flex].item {
  -webkit-flex-basis: 318px;
  flex-basis: 318px;
}

See this CodePen.

mikol avatar Mar 02 '15 19:03 mikol

I have opened problem ID 20009174 with Apple.

mikol avatar Mar 02 '15 20:03 mikol

probably even i'm facing same problem with safari 5.1.7 on windows 7 desktop. the same problem is with android 4.0(using cordova app) also. even angular-material site is not able to use flexbox on safari.(safari is on left, chrome is on right) safari-2

this is where i'm implementing. safari-1

milanart avatar Mar 03 '15 04:03 milanart

@milanart Safari for windows hasn't been updated in years. I don't really think it's a goal to support it anymore.

epelc avatar Mar 03 '15 16:03 epelc

@rschmukler - Can you look into this today?

ThomasBurleson avatar Mar 03 '15 19:03 ThomasBurleson

@epelc i know, but its not just about safari 5.1.7. but the problem is same for android 4.3 and older(with cordova). hardly few windows users use safari. but there are lots of people with android 4.3- devices.

after going through following links i was able to fix most of the flex related problems, https://css-tricks.com/old-flexbox-and-new-flexbox/ http://stackoverflow.com/questions/17156444/flexbox-layout-does-not-work-in-internet-explorer-10 https://css-tricks.com/using-flexbox/

the problem I found is there is no fix added in css

flex-direction: column; // this line is given in material.css

//these 2 lines both should be added to fix for older version
-webkit-box-direction: normal; 
-webkit-box-orient: vertical; 

there are many fixes needed for various flex properties, after fixing some of by myself i was able to achieve the following. (uploaded here http://pastebin.com/n7McpS35) still, i'm not able to solve width for flexbox. safari-3

milanart avatar Mar 04 '15 03:03 milanart

@milanart - This looks very helpful. Thank you.

ThomasBurleson avatar Mar 04 '15 04:03 ThomasBurleson

I also updated an issue already opened with WebKit: https://bugs.webkit.org/show_bug.cgi?id=136041

mikol avatar Mar 04 '15 17:03 mikol

@milanart I didn't realize it was also a problem on mobile. Sorry about this.

epelc avatar Mar 05 '15 16:03 epelc

Angular material targets android 4.4+. 4.2/4.3 only represent ~2% of web traffic according to caniuse. The safari bug is very interesting, but, out of our control. Closing.

rschmukler avatar Apr 01 '15 22:04 rschmukler

dont take it wrong but, angular material website has used css fallbacks for safari. but not provided the same in material repo. I request you to please go though my comments above . Also, may i know how much web traffic is from android 4.4?

milanart avatar Apr 07 '15 14:04 milanart

I think the issue also happened on IOS6 which uses mobile safari 5 because it only support old flex syntax

oliverzy avatar Apr 07 '15 15:04 oliverzy

Using 0.8.3 and it is still not resolved. I am not able to use the flex="x" attribute.

srameshr avatar Apr 13 '15 10:04 srameshr

@SiddharthaRRamesh - please retry with latest for /angular/material/#master

ThomasBurleson avatar Apr 13 '15 11:04 ThomasBurleson

@ThomasBurleson Yeah I did try it, still no success! The same markup works fine on chrome but not on IOS 4, 5, 6 and 6+

Here is my markup:

<div layout="row" layout-align="space-around center" layout-sm="column">
  <div flex="20">
    <img ng-src=" " hide-sm hide-md flex="20" />
 </div>
<div flex="40">
  <md-card style="min-height:370px;"></md-card>
</div>
<div flex="40">
  <md-card style="min-height:370px;"></md-card>
</div>
</div>

srameshr avatar Apr 13 '15 12:04 srameshr

i am new to angular material i have one problem with responsive.. in mobile also it's showing desktop version of website. i tried every thing.. but when i resize the chrome window it's working but on actuall mobile screen....plzz help

akashma19 avatar Jun 24 '15 06:06 akashma19

Sorry, but I don't see why this task is closed. iPhone 4s is still relevant. iPhone 5 the same. Wheather for people who are using cordova or for classic browser usage.

The main problem is that the new flexsystem is not supported and there aren't any polyfills.

So, will there be a solution to make the layout system working in iPhone 4s?

lukmadev avatar Jul 15 '15 21:07 lukmadev

@lukavent on a framework level we do not support browsers that old. I will discuss with the team to see whether it is worth compiling against the old standard as a small effort. That being said, I imagine there will be plenty of other issues besides just the layout that we will not support on the older versions. None the less, we can revisit whether it is worth including the old flex standard as an easy win.

rschmukler avatar Jul 20 '15 14:07 rschmukler

add meta tag

On Thu, Sep 17, 2015 at 6:38 PM, Pierre Paul Lefebvre < [email protected]> wrote:

I'm having the same issue on safari 8 and all iPhone versions I got access to. Any idea if it's going to be fixed or if there is a flag/easy fix to apply?

— Reply to this email directly or view it on GitHub https://github.com/angular/material/issues/1720#issuecomment-141077126.

akashma19 avatar Sep 17 '15 16:09 akashma19